search
Login

Categories


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

3.8k questions

4k answers

117 comments

10.7k users

0 votes
211 views
asked Sr Member 4.8k points 10 25 31

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 Expert 11.4k points 14 22 28

Related questions

0 votes
1 answer 28 views
28 views
asked john Guru 27.1k points 31 50 97
1 vote
1 answer 34 views
34 views
What's the simplest way of printing an array of primitives or of objects in Java? Here are some example inputs and outputs: int[] intArray = new int[] {1, 2, 3, 4, 5}; //output: [1, 2, 3, 4, 5] String[] strArray = new String[] {"John", "Mary", "Bob"}; //output: [John, Mary, Bob]
asked keem Expert 13.2k points 27 40 59
0 votes
1 answer 24 views
24 views
asked john Guru 27.1k points 31 50 97
1 vote
1 answer 20 views
20 views
asked keem Expert 13.2k points 27 40 59
0 votes
1 answer 24 views
24 views
How can I clone ArrayList but also clone its items in Java 1.5? For example I have: ArrayList<Dog> dogs = getDogs(); ArrayList<Dog> clonedList = ....something to do with dogs.... And I would expect that objects in clonedList are not the same as in dogs list.
asked john Guru 27.1k points 31 50 97
...