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
199 views
asked 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 by sunny Expert (11,410 points)

Related questions

0 votes
1 answer 26 views
26 views asked by john Guru (27,140 points)
+1 vote
1 answer 32 views
32 views asked by keem Expert (13,240 points)
0 votes
1 answer 22 views
+1 vote
1 answer 17 views
0 votes
1 answer 23 views
...