i need to find a integer data in arraylist?

arraylist, java

Solution

If you are checking to see if some value is stored in an `ArrayList` you can use the `contains()` method, this will return `true` if the object is in the list, `false` otherwise.

ArrayList<Integer> intList = new ArrayList<>();

intList.add(5);
intList.add(7);
intList.add(3);
intList.add(-2);

intList.contains(-1); //returns false
intList.contains(3); //returns true

Problem

I have an `Arraylist`. If user enter the same number secondly I want to show to user. For this I need to find `Arraylist` have it or not. I hope I made myself clear.

Original source