ArrayList

ArrayList is a way to hold reference to objects other than normal array. Unlike normal array, ArrayList can add, insert, remove objects within ArrayList. Although there are many things you can do with ArrayList, ArrayList is bulid by normal arrays. you have to import java.util.ArrayList enable to use ArrayList, or import java.util.*;. Make a new Arraylist > ArrayList x = new ArrayList'; Method of ArrayList > int size //return the number of values currently stored in the list. ex: x.size// > boolean isEmpty Returns true if the list is empty, other wise returns false. ex: x.isEmpty > boolean add(Object obj) //Appends obj at the end of the list; returns ture; ex: x.add( "asdfas" ), adds a string.// > void add( int i, Object obj) Inserts obj before the i-th element; increments the indices of the subsequent element by 1; ex: x.add( 5, "asdfasd"); > Object set( int i, Object obj) //replace i-th element with obj, returns the old value// x.set(1,"asdfa") > Object get(int i), returns the value of the i-th element > Object remove( int i) //Removes the i-th element from the list and returns its old value; decrements the indices of the subsequent elements by1. ex: x.remove(1);