How to find the index of an element in an int array?

前端 未结 19 1368
南方客
南方客 2020-11-27 02:56

How can I find an index of a certain value in a Java array of type int?

I tried using Arrays.binarySearch on my unsorted array, it only som

19条回答
  •  隐瞒了意图╮
    2020-11-27 03:01

    You can either walk through the array until you find the index you're looking for, or use a List instead. Note that you can transform the array into a list with asList().

提交回复
热议问题