Both of these are members of the Collection framework, but there is a major difference between List and ArrayList in Java. The List refers to a collection of various elements in a sequence, in which every element is basically an object. Also, we can access these elements by their positions (index). On the other hand, an ArrayList creates an array (dynamic) of the objects that can easily reduce or increase in size as and when required.
Here, the List serves as an interface while the ArrayList serves as a class. We will get into the difference between List and ArrayList in a comparison chart. But let us first know their individual functionalities.
What is List in Java?
A list is an interface that provides an extension to the collection framework. You cannot instantiate List, but you can use it for creating a list of various objects/ elements. All of these objects get associated with their respective index numbers. The List creates a collection of various elements that you can store in a sequence. It identifies these elements and accesses them using an index.
What is ArrayList in Java?
An ArrayList is a class that provides an extension to the AbstractList class. It basically implements the List interface, and you cannot instantiate it. We can use an ArrayList class for creating a dynamic array that contains various objects. It basically creates a whole array of various objects that you can develop dynamically.
Difference Between List and ArrayList in Java
Parameters | List in Java | ArrayList in Java |
Basics | The List is a type of interface. | The ArrayList is a standard type of collection class. |
Extension/ Implementation | The interface of a List provides an extension to the Collection Framework. | The ArrayList provides an extension to the List Interface. |
Syntax | It is an interface List. | It is a class ArrayList. |
Work | We can use the List for creating a list of various objects/ elements that stay associated with their index numbers. | We can use the ArrayList for creating an array (dynamic) that consists of objects. |
Keep learning and stay tuned to get the latest updates on GATE Exam along with Eligibility Criteria, GATE Application Form, Syllabus, GATE Cut off, Previous Year Question Papers, and more.
Also Explore,
Comments