ProAnswers.org

How to Create an Array List in java?

Syntax: Array List al = new Array List();

Array List al = new Array List (int initialcapacity);



Here, E represents element data type



Methods of Array List:




	[b]Boolean add(Element obj)[/b]: this method is used to place the specified element to the end of List.

	[b]Void add(int position, Element obj)[/b]: this method is used to insert and element at the specified position.

	[b]Boolean remove(Element obj)[/b]: this method is used to remove the 1st occurrence of the specified element.

	[b]Element remove(int position)[/b]: this method is used to remove and Element from the specified position.

	[b]Void clear()[/b]: this method remove all the elements available in the Array List.

	[b]Int Size()[/b]: this method will return the count of the no.of elements available in the Array List.

	[b]Boolean contains(element obj)[/b]: this method returns true if the specified element is available in the Array List.

	[b]Element get(int position)[/b]: this method is used to access an Element that is available in the specified position.

	[b]Element set(int position, Element obj)[/b]: this method is used replace an element in the specified position with the specified element.