1.

Difference Between Array And Arraylist In Java?

Answer»
  • ARRAY is fixed in size which is provided at the time of creating an Array. ArrayList grows DYNAMICALLY and also known as dynamically growing array.
  • Array can store PRIMITIVE types as well as objects. In ArrayList only Objects can be stored.
  • Arrays can be multi-dimensional whereas ArrayList is always unidimensional.

    As Exp. a two dimensional array can be created as -

    Integer MYARRAY[][] = new Integer[4][3];

  • Performance wise both Array and ArrayList are almost same as internally ArrayList also uses an Array. But there is overhead of resizing the array and copying the elements to the new Array in case of ArrayList.



Discussion

No Comment Found