Wednesday, 12 October 2016

java.util.ArrayList class

java.util.ArrayList class

java.util.ArrayList class
  • We can store group of objects in ArrayList object.
  • Here group of objects means, it can allow us to store same type of objects and different type of objects.
    • Same type means, assuming that all objects are in the form of integer types.
    • Different type means, assuming that all objects are in the form of integer, float, String, Student and Customer types also.
  • ArrayList extends AbstractList class which is a abstract class and implements List interface.
  • Size will increase dynamically.
  • ArrayList is non synchronized.
  • We can get the objects in Random order because ArrayList works on index based.
  • The process of ArrayList is very slow, if you are inserting and removing the objects from middle of the ArrayList.
Inherited features from List
  • We will get the output according to insertion order.
  • Allows duplicate objects.
Program         :       Example on ArrayList class
Program name  :
Output            :         
      [1, Nireekshan, A, 1.1, 1.12345]
import java.util.ArrayList;
class ALDemo1
public static void main(String args[])
ArrayList arrayList = new ArrayList();




Compile       :         javac
Run             :         java ALDemo1
Output        :         
     [1, Nireekshan, A, 1.1, 1.12345]
Thanks for your time.
- Nireekshan