Difference between length of Array and size of ArrayList in Java Last Updated : 25 Oct, 2024 Comments Improve Suggest changes Like Article Like Report Array and ArrayList are two different Entities in Java. In this article we will learn the difference between length of Array and size of ArrayList in Java.Array has length property which provides the length of the Array or Array object. It is the total space allocated in memory during the initialization of the array. Array is static so when we create an array of size n then n blocks are created of array type and JVM initializes every block by default value. Let's see this in the following figure. On the other hand, java ArrayList does not have length property. The java ArrayList has size() method for ArrayList which provides the total number of objects available in the collection.We use length property to find length of Array in Java and size() to find size of ArrayList.Below is the implementation of the above idea: Java // Java code to illustrate the difference between // length in java Array and size in ArrayList import java.util.ArrayList; public class GFG { public static void main(String[] args) { String a[] = new String[10]; a[0] = "Hello"; a[1] = "Geeks!"; // print length of array A[] System.out.println(a.length); ArrayList<String> al = new ArrayList<String>(); al.add("G"); al.add("F"); al.add("G"); // print size of ArrayList System.out.println(al.size()); } } Output10 3 Comment More infoAdvertise with us Next Article Difference between length of Array and size of ArrayList in Java R rajput-ji Follow Improve Article Tags : Java Technical Scripter Difference Between Technical Scripter 2018 Java-Arrays Java-ArrayList Java-Array-Programs Java-List-Programs +4 More Practice Tags : Java Similar Reads Difference between List and ArrayList in Java A Collection is a group of individual objects represented as a single unit. Java provides a Collection Framework which defines several classes and interfaces to represent a group of objects as a single unit This framework consists of the List Interface as well as the ArrayList class. In this article 4 min read Difference Between Arrays.toString() and Arrays.deepToString() in Java The deepToString() method of the Arrays class returns the string representation of the deep contents of the specified Object array. Unlike Arrays. toString(), if the array contains other arrays as elements, the string representation includes their contents, and so on. Arrays.toString(): Returns a st 3 min read Difference between Array and String in Java An array is a collection of similar type of elements that are stored in a contiguous memory location. Arrays can contain primitives(int, char, etc) as well as object(non-primitives) references of a class depending upon the definition of the array. In the case of primitive data type, the actual value 5 min read Difference between ArrayList and HashSet in Java Here are couple of differences between ArrayList and HashSet. Inheritance: Implementation: Implementation : ArrayList implements List interface while HashSet implements Set interface in Java.Internal implementation: ArrayList is backed by an Array while HashSet is backed by an HashMap.Duplicates : A 3 min read Difference between List, Set and Map in Java List interface in Java is a sub-interface of the Java collections interface. It contains the index-based methods to insert, update, delete, and search the elements. It can have duplicate elements also. We can also store the null elements in the list. List preserves the insertion order, it allows pos 4 min read Like