3

I have taken an int[] as input. For searching the index of an integer in the array I used Arrays.asList(arr).indexOf(element) method. However, I am getting index as -1 even if the element is present in the array.

1
  • 1
    Post the code and sample data for which you get this output. Commented Jun 14, 2017 at 9:52

1 Answer 1

2

int[] is one object, so Arrays.asList(arr) puts one object in the list, you need to put values from int[] one by one

Sign up to request clarification or add additional context in comments.

1 Comment

Or use Arrays.stream(array).boxed().collect(Collectors.toList()).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.