Monday, March 24, 2014

Java ArrayList

  • Java ArrayList

 Java class ArrayList(java.util.ArrayList) is a fast and easy to use class representing one-dimensional array.
 ArrayList is not synchronized i.e. using it in more that one thread may cause problems.

 ArrayList class provides methods for basic array operations:

    add( Object o ) - puts reference to object into ArrayList
    get( int index ) - retrieves object reference from ArrayList index position
    size() - returns ArrayList size
    remove( int index ) - removes the element at the specified position in this list. Shifts any subsequent elements to the left and returns the element that was removed from the list.
    indexOf( Object o) - finds the index in this list of the first occurrence of the specified element
    clear() - removes all of the elements
   
    http://www.anyexample.com/programming/java/java_arraylist_example.xml

No comments:

Post a Comment