| Difference between Array and ArrayList?
Below are the main difference between Array and ArrayList:-
(1)Array:-Arrays of parameterized types are not allowed.
(1)ArrayList:-Arraylists are type
(2)ArrayArray cannot contain values of different data types.
(2)ArrayList:-ArrayList contains values of different data types.
(3)ArrayIn array we need to define the size of array.
(3)ArrayList:-In arraylist size can be changed dynamically.
(4)ArrayArray can contain primitive data types as well as objects.
(4)ArrayList:-Arryalist can contain only objects and no primitive data types are allowed.
(5)ArrayIn Arraylist we only need to specify the index to add data/
(5)ArrayList:-we donot worry about to specify the index.
(6)ArrayArray are static
(6)ArrayList:-Arraylist are dynamic
(7)ArrayTo put any element in array we need to know the position.
(7)ArrayList:-Here we can add element by using add method.
(8)ArrayIt is part of core java programming.
(8)ArrayList:-ArrayList is a part of collection framework with other classes such as vector, hashmap etc. | | |