I am not able to make the difference between ArrayList and Array of objects in java. I am just a beginner. Also I am not able to understand that why Array is sorted by Arrays.sort and ArrayList is sorted by Collections.sort if both are array only.
Asked
Active
Viewed 1,213 times
-6
-
1https://www.google.co.uk/?gws_rd=ssl#safe=off&q=arraylist+vs+array+java – Sleiman Jneidi Feb 23 '16 at 20:30
-
1Hey Parth, definitely check out those links provided. There are several types of arrays, and they use different notions of natural ordering in sort. – MathBio Feb 23 '16 at 20:31
-
why they use different object for sorting – Patel Parth Feb 23 '16 at 20:31
-
1As far as Java's concerned, they're nothing like the same type. `ArrayList` has an array in its implementation, but as far as Java's concerned that's the only overlap. – Louis Wasserman Feb 23 '16 at 20:32
-
Also i want to know that Collections is an object or interface? – Patel Parth Feb 23 '16 at 20:33
-
1`Collections` is a class that can't be instantiated, so, neither. `Collection` is an interface. – Louis Wasserman Feb 23 '16 at 20:34
-
does it mean that it is final class – Patel Parth Feb 23 '16 at 20:35
-
1@ParthPatel No, it just has a private constructor. – Louis Wasserman Feb 23 '16 at 20:41
-
when i see in javadoc, i find that there is no constructor. then why you are telling that it has private constructor/ – Patel Parth Feb 23 '16 at 20:44
1 Answers
2
The short answer is arrays have a set size you define where as an arraylist has infinite size. You'll learn a lot about them from the api
https://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Array.html
https://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html

Zach
- 640
- 1
- 8
- 20