# How to find the indexing value of a number in an integer array?

**URL:** <https://forum.codewithmosh.com/t/how-to-find-the-indexing-value-of-a-number-in-an-integer-array/3412>\
**Category:** Java\
**Created:** [March 18, 2021, 6:27am UTC](https://forum.codewithmosh.com/t/how-to-find-the-indexing-value-of-a-number-in-an-integer-array/3412 "2021-03-18T06:27:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mongopulp](https://avatars.discourse-cdn.com/v4/letter/m/ec9cab/32.png) [@mongopulp](https://forum.codewithmosh.com/u/mongopulp)\
**Post date:** [March 18, 2021, 6:27am UTC](https://forum.codewithmosh.com/t/how-to-find-the-indexing-value-of-a-number-in-an-integer-array/3412/1 "2021-03-18T06:27:39Z")

</div>

I have a java related question - **if we have an integer array of size 5. Then how can we find the indexing value of a number in this integer array?**

**PLEASE TAKE THE INTEGER ARRAY AS { 2,1,4,3,6 }**

Earlier I tried doing this with the **indexOf()** method but there was an error when I ran the program.

---

<div class="post-metadata">

**Author:** ![jmrunkle](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/jmrunkle/32/3765_2.png) [@jmrunkle](https://forum.codewithmosh.com/u/jmrunkle)\
**Post date:** [August 17, 2022, 11:24pm UTC](https://forum.codewithmosh.com/t/how-to-find-the-indexing-value-of-a-number-in-an-integer-array/3412/2 "2022-08-17T23:24:27Z")

</div>

Could you paste your code and clarify the intended behavior? A few inputs with expected output should suffice.
