Syntax: Array List<E> al = new Array List<E>();
Array List<E> al = new Array List <E>(int initialcapacity);
Here, E represents element data type
Methods of Array List:
-
Boolean add(Element obj): this method is used to place the specified element to the end of List.
-
Void add(int position, Element obj): this method is used to insert and element at the specified position.
-
Boolean remove(Element obj): this method is used to remove the 1st occurrence of the specified element.
-
Element remove(int position): this method is used to remove and Element from the specified position.
-
Void clear(): this method remove all the elements available in the Array List.
-
Int Size(): this method will return the count of the no.of elements available in the Array List.
-
Boolean contains(element obj): this method returns true if the specified element is available in the Array List.
-
Element get(int position): this method is used to access an Element that is available in the specified position.
-
Element set(int position, Element obj): this method is used replace an element in the specified position with the specified element.