{"id":1888,"date":"2019-01-24T12:00:00","date_gmt":"2019-01-24T11:00:00","guid":{"rendered":"https:\/\/kindsonthegenius.com\/blog\/difference-between-list-and-arraylist-in-java\/"},"modified":"2026-07-05T03:22:13","modified_gmt":"2026-07-05T01:22:13","slug":"difference-between-list-and-arraylist-in-java","status":"publish","type":"post","link":"https:\/\/kindsonthegenius.com\/blog\/difference-between-list-and-arraylist-in-java\/","title":{"rendered":"Difference Between List and ArrayList in Java"},"content":{"rendered":"<p>We would examine all the differences between List and ArrayList in Java.<\/p>\n<p>First, I would like to say that both List and ArrayList are useful classes in Java. They both allow you to work with collection of item (whether primitive types or objects).<\/p>\n<p>&nbsp;<\/p>\n<ol>\n<li><a href=\"#t1\">About Lists<\/a><\/li>\n<li><a href=\"#t2\">About ArrayList<\/a><\/li>\n<li><a href=\"#t3\">Difference Between List and ArrayList<\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t1\">1. About List<\/strong><\/h4>\n<p>First note that\u00a0 List is an interface. So this means, you cannot instantiate it.<\/p>\n<p>The List interface is available in Java.util.collection. It is derived from the Collection interface. A List is an ordered collection of objects which allows storage of duplicate values.<\/p>\n<p>The List interface is implemented by the following classes:<\/p>\n<ul>\n<li>ArrayList<\/li>\n<li>LinkedList<\/li>\n<li>Vector<\/li>\n<li>Stack<\/li>\n<\/ul>\n<p><strong>How to create a list<\/strong><\/p>\n<p>If List is an interface and we cannot instantiate an interface, how then can we create a List? We do this using the constructor from any of the classes the implements the List interface. For example, see the code below<!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\">\tList list1 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> ArrayList<span style=\"color: #333333;\">();<\/span>\n\tList<span style=\"color: #333333;\">&lt;<\/span>Integer<span style=\"color: #333333;\">&gt;<\/span> list2 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Stack<span style=\"color: #333333;\">();<\/span>\t\n\tList list3 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> LinkedList<span style=\"color: #333333;\">();<\/span>\n<\/pre>\n<p>&nbsp;<\/p>\n<p>From the code, you can see that lists are created by calling the constructor of the derived classes.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t2\">2. About ArrayList<\/strong><\/h4>\n<p>As mentioned before, an ArrayList implements the List interface.<\/p>\n<p>ArrayList is similar to List. But unlike List, an ArrayList has specific method that are only available in the ArrayList class.<\/p>\n<p>So to create an ArrayList, you use the ArrayList Constructor. See below<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\">\tArrayList alist1 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> ArrayList<span style=\"color: #333333;\">();<\/span>\n\tArrayList<span style=\"color: #333333;\">&lt;<\/span>String<span style=\"color: #333333;\">&gt;<\/span> alist2 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> ArrayList<span style=\"color: #333333;\">&lt;<\/span>String<span style=\"color: #333333;\">&gt;();<\/span>\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Similar to the List class, if an ArrayList is being created, you can decide to specify the datatype. If not specified, the default of object is used.<\/p>\n<h4><strong id=\"t3\">3. Differences Between List and ArrayList<\/strong><\/h4>\n<ul>\n<li>An ArrayList is always a List but a List is not always an ArrayList<\/li>\n<li>An ArrayList derives from the List interface<\/li>\n<li>You create List using a constructor of one of its subclasses<\/li>\n<li>You cannot Instantiate a List (of course, you cannot instantiate an interface). However, you can instantiate an ArrayList<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We would examine all the differences between List and ArrayList in Java. First, I would like to say that both List and ArrayList are useful &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"pagelayer_contact_templates":[],"_pagelayer_content":"","footnotes":""},"categories":[85],"tags":[],"class_list":["post-1888","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/1888","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/comments?post=1888"}],"version-history":[{"count":1,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/1888\/revisions"}],"predecessor-version":[{"id":2056,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/1888\/revisions\/2056"}],"wp:attachment":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/media?parent=1888"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/categories?post=1888"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/tags?post=1888"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}