0

Array and ArrayList

difference between these two pls??

6th Jan 2017, 6:54 PM
pons ponmudi
pons ponmudi - avatar
5 Respostas
+ 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.
6th Jan 2017, 7:01 PM
Andrii Voloshchuk
Andrii Voloshchuk - avatar
+ 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
10th Jan 2017, 2:40 PM
Christian Wiesner
+ 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.
6th Jan 2017, 7:03 PM
Natalia Andrianova
0
great!! anything else??
6th Jan 2017, 7:03 PM
pons ponmudi
pons ponmudi - avatar
0
thanks!! makes sense
6th Jan 2017, 7:04 PM
pons ponmudi
pons ponmudi - avatar