int size(): returns the number of elements in a array.
Boolean isEmpty():returns true if list is empty falsi if it isn’t.
Boolean add(objectType element) : returns true and adds element to the end of the list
Void add( int i, E element):insert element at ith position and shifts elements to fit it( increments the elements at i and after by 1.
ObjectType get(int i) : returns value if ith element
ObjectType set(int i, ObjectType element): replaces the ith element and returns the old value.
ObjectType remove (int i) removes ith element and returns its value.
Boolean contains (Object obj) returns true if the list has the object (equals method used for comparison).
Int indexOf(Object obj) returns index of the first occurence of obj in this arraylist, or -1 if it isn’t found.
String toString() returns a string representation of the list.
A link to the full list of refrences is below:
One thought on “common arrayList methods”
Comments are closed.