Home Java SCJP SCWCD Servlet Submit News Contact Us Site Map


Over 500 magazines for free (including Oracle Magazine)!

Yes all of them are FREE. You can subscribe to ALL of them.
Click here to apply today!

Methods to Search elements within Java ArrayList

Java ArrayList provides following methods to search a particular element within the ArrayList.

1) int indexOf(Object element)

Search for a particular element in the ArrayList and return the position of the first occurrence of the element if found within the list, otherwise returns -1.

2) intLastIndexOf(Object element)

Search for a particular element in the ArrayList and return the position of the last occurrence of the element if found within the list, otherwise returns -1.

3) int size()

Returns the number of elements contained in the list.

4) boolean isEmpty()

Returns true of the list is empty, otherwise returns false.

5) boolean contains(Object element)

Returns true if the specified element is found in the list, otherwise returns false.

<<Add Elements to Java ArrayList

Remove, Replace, Search Elements from Java ArrayList >>

Home Java SCJP SCWCD Servlet Site map