0
Array and ArrayList
difference between these two pls??
5 odpowiedzi
+ 4
Array has fixed size when created, you need to recreate it each time you want to add more elements.
ArrayList auto expands when you add new elements.
+ 2
An array has to be declared with a specific type (e.g. int) and is restricted to that type.
An ArrayList can be declared without a specific type and you can decide later in the program what type of data it shall store, e.g. Integer, Double, String ...
The ArrayList class comes with several useful methods which help to manipulate the data/objects in it, e.g. get, set, add, remove, removeAll, removeRange, iterator ...
http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html
+ 1
Array is static in size that is fixed length data structure, One can not change the length after creating the Array object.
ArrayList is dynamic in size . Each ArrayList object has instance variable capacity which indicates the size of the ArrayList. As elements are added to an ArrayList its capacity grows automatically.
ArrayList can not contains primitive data types (like int , float , double) it can only contains Object while Array can contain both primitive data types as well as objects.
Array can be multi dimensional , while ArrayList is always single dimensional.
0
great!! anything else??
0
thanks!! makes sense