C Books Guide and List
C++ Books Guide and List
Best Java Books

3,749 questions

4,049 answers

114 comments

10,705 users

How to Create an Array List in java?

0 votes
185 views
asked May 14, 2014 by augustaina Sr Member (4,820 points)

1 Answer

0 votes

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:

  1. Boolean add(Element obj): this method is used to place the specified element to the end of List.
  2. Void add(int position, Element obj): this method is used to insert and element at the specified position.
  3. Boolean remove(Element obj): this method is used to remove the 1st occurrence of the specified element.
  4. Element remove(int position): this method is used to remove and Element from the specified position.
  5. Void clear(): this method remove all the elements available in the Array List.
  6. Int Size(): this method will return the count of the no.of elements available in the Array List.
  7. Boolean contains(element obj): this method returns true if the specified element is available in the Array List.
  8. Element get(int position): this method is used to access an Element that is available in the specified position.
  9. Element set(int position, Element obj): this method is used replace an element in the specified position with the specified element.
answered May 14, 2014 by sunny Expert (11,410 points)

Related questions

0 votes
1 answer 25 views
25 views asked Apr 25, 2014 by john Guru (27,140 points)
+1 vote
1 answer 31 views
31 views asked Jan 24, 2014 by keem Expert (13,240 points)
0 votes
1 answer 22 views
22 views asked Jan 9, 2014 by john Guru (27,140 points)
+1 vote
1 answer 17 views
17 views asked Jan 24, 2014 by keem Expert (13,240 points)
0 votes
1 answer 23 views
23 views asked Jan 30, 2014 by john Guru (27,140 points)
...