{"id":122313,"date":"2020-05-01T13:05:52","date_gmt":"2020-05-01T13:05:52","guid":{"rendered":"https:\/\/www.softwaretestinghelp.com\/?page_id=122313"},"modified":"2025-04-01T08:30:35","modified_gmt":"2025-04-01T08:30:35","slug":"java-arraylist-conversions","status":"publish","type":"page","link":"https:\/\/www.softwaretestinghelp.com\/java-arraylist-conversions\/","title":{"rendered":"Java ArrayList Conversions To Other Collections"},"content":{"rendered":"<p><strong>This Tutorial Discusses ArrayList Conversions to other Collections like Set, LinkedList, Lists, etc. along with Differences Between These Collections:<\/strong><\/p>\n<p>So far we have seen almost all the concepts related to ArrayList in Java. Apart from creating and manipulating ArrayList using various operations or methods provided by ArrayList class, sometimes it is also required to convert ArrayList to one or more collections.<\/p>\n<p><strong>=&gt; <a href=\"https:\/\/www.softwaretestinghelp.com\/java\/\">Visit Here To Learn Java From Scratch.<\/a><\/strong><\/p>\n<p><em><strong> <\/strong><\/em><\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/Array-list-Conversion1.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-122669\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/Array-list-Conversion1.png\" alt=\"Array list Conversion\" width=\"650\" height=\"366\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/Array-list-Conversion1.png 650w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/Array-list-Conversion1-300x169.png 300w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/a><\/p>\n<p><em><strong>In this tutorial, we will discuss some of the conversions from ArrayList to other collections that include List, LinkedList, Vector, Set, etc. We will also consider conversion between ArrayList and String. After conversions, we will also discuss the differences between ArrayLists and other Collections &#8211; Arrays, List, Vector, LinkedList, etc.<\/strong><\/em><\/p>\n<h3>ArrayList To String Conversion<\/h3>\n<p><strong>The following methods can be used to convert ArrayList to String.<\/strong><\/p>\n<p><strong>#1) Using a StringBuilder object<\/strong><\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">import java.util.ArrayList;\r\n\r\npublic class Main {\r\n   public static void main(String args&#x5B;]) {\r\n       \/\/Create and initialize the ArrayList\r\n      ArrayList&lt;String&gt; strList = new ArrayList&lt;String&gt;();\r\n      strList.add(&quot;Software&quot;);\r\n      strList.add(&quot;Testing&quot;);\r\n      strList.add(&quot;Help&quot;);\r\n      \/\/print the ArrayList\r\n      System.out.println(&quot;The ArrayList: &quot; + strList);\r\n      \/\/define a stringbuilder object     \r\n      StringBuffer sb = new StringBuffer();\r\n      \r\n      \/\/append each ArrayList element to the stringbuilder object\r\n      for (String str : strList) {\r\n         sb.append(str + &quot; &quot;);\r\n      }\r\n      \/\/convert stringbuilder to string and print it.\r\n      String myStr = sb.toString();\r\n      System.out.println(&quot;\\nString from ArrayList: &quot; + myStr);\r\n   }\r\n} <\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>The ArrayList: [Software, Testing, Help]<br \/>\nString from ArrayList: Software Testing Help<\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/1-4.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-122324\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/1-4.png\" alt=\"output\" width=\"382\" height=\"36\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/1-4.png 382w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/1-4-300x28.png 300w\" sizes=\"(max-width: 382px) 100vw, 382px\" \/><\/a><\/p>\n<p>In the above program, a StringBuilder object is created. Then using the forEach loop, each element in the ArrayList is appended to the StringBuilder object. Then the StringBuilder object is converted to a string. Note that using the StringBuilder \u2018append\u2019 method; you can also append appropriate delimiter to the string.<\/p>\n<p>In the above example, we have used space (\u201c \u201c) as the delimiter.<\/p>\n<p><strong>#2) Using String.join () method<\/strong><\/p>\n<p>The method String.join () can be used to convert the ArrayList to String. Here, you can also pass appropriate delimiter to the join method.<\/p>\n<p><strong> The program below demonstrates this.<\/strong><\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">import java.util.ArrayList;\r\n\r\npublic class Main {\r\n    public static void main(String&#x5B;] args) {\r\n        \/\/ create and initialize the ArrayList\r\n        ArrayList&lt;String&gt; metroList = new ArrayList&lt;&gt;();\r\n        metroList.add(&quot;Delhi&quot;);\r\n        metroList.add(&quot;Mumbai&quot;);\r\n        metroList.add(&quot;Chennai&quot;);\r\n        metroList.add(&quot;Kolkata&quot;);\r\n        \/\/print the ArrayList\r\n        System.out.println(&quot;The ArrayList: &quot; + metroList);\r\n        \/\/ Join with an empty delimiter to concat all strings.\r\n        String resultStr = String.join(&quot; &quot;, metroList);\r\n        System.out.println(&quot;\\nString converted from ArrayList: &quot;+resultStr);\r\n    }\r\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>The ArrayList: [Delhi, Mumbai, Chennai, Kolkata]<br \/>\nString converted from ArrayList: Delhi Mumbai Chennai Kolkata<\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/2-3.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-122325\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/2-3.png\" alt=\"output\" width=\"529\" height=\"53\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/2-3.png 529w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/2-3-300x30.png 300w\" sizes=\"(max-width: 529px) 100vw, 529px\" \/><\/a><\/p>\n<p>You can see that we directly pass the ArrayList as an argument to the String.join () method along with the delimiter.<\/p>\n<p>For simple String ArrayLists, String.join () is the best method to convert to String. But for more complex ArrayLists objects, using StringBuilder is more efficient.<\/p>\n<h3>String To ArrayList Conversion<\/h3>\n<p><strong>In order to convert a String to ArrayList, there are two steps:<\/strong><\/p>\n<ol>\n<li>The string is split using the split () function and the substrings (split on appropriate delimiter) are stored in a string array.<\/li>\n<li>The string array obtained from splitting the string is then converted to ArrayList using \u2018asList()\u2019 method of the Arrays class.<\/li>\n<\/ol>\n<p><strong>The program to convert string to ArrayList is given below.<\/strong><\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">import java.util.ArrayList;\r\nimport java.util.List;\r\nimport java.util.Arrays;\r\npublic class Main {\r\n    public static void main(String args&#x5B;]){\r\n    \/\/define a string\r\n\tString myStr = &quot;The string to ArrayList program&quot;;\r\n    \/\/convert string to array using split function on spaces\r\n\tString strArray&#x5B;] = myStr.split(&quot; &quot;);\r\n\t\/\/print the string\r\n\tSystem.out.println(&quot;The input string : &quot; + myStr);\r\n    \/\/declare an ArrayList\r\n\tList&lt;String&gt; strList = new ArrayList&lt;String&gt;();\r\n\t\/\/convert string array to ArrayList using asList method\r\n\tstrList = Arrays.asList(strArray);\r\n    \/\/print the resultant ArrayList\r\n    System.out.println(&quot;\\nThe ArrayList from String:&quot; + strList );\r\n   }\r\n} <\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>The input string: The string to ArrayList program<br \/>\nThe ArrayList from String:[The, string, to, ArrayList, program]<\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/3-3.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-122326\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/3-3.png\" alt=\"output\" width=\"549\" height=\"56\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/3-3.png 549w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/3-3-300x31.png 300w\" sizes=\"(max-width: 549px) 100vw, 549px\" \/><\/a><\/p>\n<p>In the above program, we split the string into spaces and collect it in a string array. This array is then converted into an ArrayList of strings.<\/p>\n<h3>Convert list To ArrayList In Java<\/h3>\n<p>ArrayList implements the List interface. If you want to convert a List to its implementation like ArrayList, then you can do so using the addAll method of the List interface.<\/p>\n<p><strong>The program below shows the conversion of the list to ArrayList by adding all the list elements to the ArrayList.<\/strong><\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">import java.util.ArrayList;\r\nimport java.util.List;\r\n \r\npublic class Main {\r\n    public static void main(String a&#x5B;]){\r\n        \/\/create a list &amp; initiliaze it\r\n        List&lt;String&gt; collections_List = new ArrayList&lt;String&gt;();\r\n        collections_List.add(&quot;ArrayList&quot;);\r\n        collections_List.add(&quot;Vector&quot;);\r\n        collections_List.add(&quot;LinkedList&quot;);\r\n        collections_List.add(&quot;Stack&quot;);\r\n        collections_List.add(&quot;Set&quot;);\r\n        collections_List.add(&quot;Map&quot;);\r\n        \/\/print the list\r\n        System.out.println(&quot;List contents: &quot;+collections_List);\r\n        \/\/create an ArrayList        \r\n        ArrayList&lt;String&gt; myList = new ArrayList&lt;String&gt;();\r\n        \/\/use addAll() method to add list elements to ArrayList\r\n        myList.addAll(collections_List);\r\n        \/\/print the ArrayList\r\n        System.out.println(&quot;\\nArrayList after adding elements: &quot;+myList);\r\n    }\r\n}\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>List contents: [ArrayList, Vector, LinkedList, Stack, Set, Map]<br \/>\nArrayList after adding elements: [ArrayList, Vector, LinkedList, Stack, Set, Map]<\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/4-2.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-122327\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/4-2.png\" alt=\"output\" width=\"630\" height=\"73\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/4-2.png 630w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/4-2-300x35.png 300w\" sizes=\"(max-width: 630px) 100vw, 630px\" \/><\/a><\/p>\n<h3>Convert ArrayList To Set In Java<\/h3>\n<p><strong>The following methods convert an ArrayList to a Set.<\/strong><\/p>\n<p><strong>#1) Using a traditional iterative approach<\/strong><\/p>\n<p>This is the traditional approach. Here, we iterate through the list and add each element of the ArrayList to the set.<\/p>\n<p>In the program below, we have an ArrayList of string. We declare a HashSet of string. Then using the forEach loop, we iterate over the ArrayList and add each element to the HashSet.<\/p>\n<p>In a similar manner, we can also convert ArrayList to a treeSet.<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">import java.util.*; \r\n  \r\nclass Main { \r\n    public static void main(String&#x5B;] args)  { \r\n          \/\/ Create &amp; initialize an ArrayList\r\n        ArrayList&lt;String&gt; colorsList = new ArrayList&lt;String&gt;\r\n        (Arrays.asList(&quot;Red&quot;, &quot;Green&quot;, &quot;Blue&quot;, &quot;Cyan&quot;, &quot;Magenta&quot;, &quot;Yellow&quot;)); \r\n        \/\/print the ArrayList\r\n        System.out.println(&quot;The ArrayList:&quot; + colorsList);\r\n        \/\/Declare a HashSet\r\n        Set&lt;String&gt; hSet = new HashSet&lt;String&gt;(); \r\n        \/\/Add each ArrayList element to the set\r\n        for (String x : colorsList) \r\n            hSet.add(x); \r\n        \/\/Print the HashSet  \r\n        System.out.println(&quot;\\nHashSet obtained from ArrayList: &quot; + hSet); \r\n     } \r\n}\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>The ArrayList:[Red, Green, Blue, Cyan, Magenta, Yellow]<br \/>\nHashSet obtained from ArrayList: [Red, Cyan, Blue, Yellow, Magenta, Green]<\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/5-2.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-122328\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/5-2.png\" alt=\"output\" width=\"571\" height=\"66\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/5-2.png 571w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/5-2-300x35.png 300w\" sizes=\"(max-width: 571px) 100vw, 571px\" \/><\/a><\/p>\n<p><strong>#2) Using Set Constructor<\/strong><\/p>\n<p>The next method to convert an ArrayList to a set is using the constructor. In this method, we pass the ArrayList as an argument to the set constructor and thus initialize the set object with ArrayList elements.<\/p>\n<p><strong>The program below shows the use of ArrayList in creating a set object.<\/strong><\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">import java.util.*; \r\n  \r\nclass Main { \r\n    public static void main(String&#x5B;] args)  { \r\n          \/\/ Create &amp; initialize an ArrayList\r\n        ArrayList&lt;String&gt; colorsList = new ArrayList&lt;String&gt;\r\n        (Arrays.asList(&quot;Red&quot;, &quot;Green&quot;, &quot;Blue&quot;, &quot;Cyan&quot;, &quot;Magenta&quot;, &quot;Yellow&quot;)); \r\n        \/\/print the ArrayList\r\n        System.out.println(&quot;The ArrayList:&quot; + colorsList);\r\n        \/\/Declare a TreeSet\r\n       Set&lt;String&gt; tSet = new TreeSet&lt;String&gt;(colorsList); \r\n       \/\/Print the TreeSet  \r\n        System.out.println(&quot;\\nTreeSet obtained from ArrayList: &quot; + tSet); \r\n    } \r\n}\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>The ArrayList:[Red, Green, Blue, Cyan, Magenta, Yellow<br \/>\nTreeSet obtained from ArrayList: [Blue, Cyan, Green, Magenta, Red, Yellow]<\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/6-1.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-122329\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/6-1.png\" alt=\"output\" width=\"626\" height=\"57\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/6-1.png 626w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/6-1-300x27.png 300w\" sizes=\"(max-width: 626px) 100vw, 626px\" \/><\/a><\/p>\n<p><strong>#3) Using The addAll Method<\/strong><\/p>\n<p>You can also use the addAll method of Set to add all the elements of ArrayList to the set.<\/p>\n<p><strong>The following program uses the addAll method to add the elements of ArrayList to the HashSet.<\/strong><\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">import java.util.*; \r\n \r\nclass Main { \r\n    public static void main(String&#x5B;] args)  { \r\n        \/\/ Create &amp; initialize an ArrayList\r\n        ArrayList&lt;String&gt; colorsList = new ArrayList&lt;String&gt;\r\n        (Arrays.asList(&quot;Red&quot;, &quot;Green&quot;, &quot;Blue&quot;, &quot;Cyan&quot;, &quot;Magenta&quot;, &quot;Yellow&quot;)); \r\n        \/\/print the ArrayList\r\n        System.out.println(&quot;The ArrayList:&quot; + colorsList);\r\n        \/\/Declare a HashSet\r\n        Set&lt;String&gt; hSet = new HashSet&lt;String&gt;(); \r\n        \/\/use addAll method of HashSet to add elements of ArrayList\r\n        hSet.addAll(colorsList);\r\n        \/\/Print the HashSet  \r\n        System.out.println(&quot;\\nHashSet obtained from ArrayList: &quot; + hSet); \r\n     } \r\n}\r\n<\/pre>\n<p><strong> Output:<\/strong><\/p>\n<p>The ArrayList:[Red, Green, Blue, Cyan, Magenta, Yellow]<br \/>\nHashSet obtained from ArrayList: [Red, Cyan, Blue, Yellow, Magenta, Green]<\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/7-1.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-122330\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/7-1.png\" alt=\"output\" width=\"624\" height=\"56\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/7-1.png 624w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/7-1-300x27.png 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/a><\/p>\n<p><strong>#4) Using Java 8 Stream<\/strong><\/p>\n<p>Streams are the new additions to Java 8. This stream class provides a method to convert ArrayList to stream and then to set.<\/p>\n<p><strong>The Java program below demonstrates the use of the stream class method to convert ArrayList to set.<\/strong><\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">import java.util.*; \r\nimport java.util.stream.*; \r\nclass Main { \r\n    public static void main(String&#x5B;] args)  { \r\n        \/\/ Create &amp; initialize an ArrayList\r\n        ArrayList&lt;String&gt; colorsList = new ArrayList&lt;String&gt;\r\n        (Arrays.asList(&quot;Red&quot;, &quot;Green&quot;, &quot;Blue&quot;, &quot;Cyan&quot;, &quot;Magenta&quot;, &quot;Yellow&quot;)); \r\n        \/\/print the ArrayList\r\n        System.out.println(&quot;The ArrayList:&quot; + colorsList);\r\n        \r\n        \/\/ Convert ArrayList to set using stream \r\n        Set&lt;String&gt; set = colorsList.stream().collect(Collectors.toSet()); \r\n  \r\n        \/\/Print the Set  \r\n        System.out.println(&quot;\\nSet obtained from ArrayList: &quot; + set); \r\n     } \r\n}\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>The ArrayList:[Red, Green, Blue, Cyan, Magenta, Yellow]<br \/>\nSet obtained from ArrayList: [Red, Cyan, Blue, Yellow, Magenta, Green]<\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/8.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-122343\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/8.png\" alt=\"output\" width=\"595\" height=\"54\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/8.png 595w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/8-300x27.png 300w\" sizes=\"(max-width: 595px) 100vw, 595px\" \/><\/a><\/p>\n<h3>Convert Set To ArrayList In Java<\/h3>\n<p>In the last section, we have seen the conversion of ArrayList to Set. The conversion from Set to ArrayList also uses the same methods as described above with the difference that the position of the set and ArrayList changes.<\/p>\n<p>Given below are programming examples to convert Set to ArrayList. The other description for each method remains the same.<\/p>\n<p><strong>#1) Iterative Approach<\/strong><\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">import java.util.*; \r\n  \r\nclass Main { \r\n  public static void main(String&#x5B;] args) { \r\n      \/\/ Create a set of strings &amp; add elements to it \r\n    Set&lt;String&gt; set = new HashSet&lt;String&gt;(); \r\n    set.add(&quot;One&quot;); \r\n    set.add(&quot;Two&quot;); \r\n    set.add(&quot;Three&quot;); \r\n    \/\/print the set\r\n    System.out.println(&quot;The given Set: &quot; + set); \r\n    \/\/create an ArrayList  \r\n    ArrayList&lt;String&gt; numList = new ArrayList&lt;String&gt;(set.size()); \r\n    \/\/add each set element to the ArrayList using add method\r\n    for (String str : set) \r\n      numList.add(str); \r\n  \r\n    \/\/print the ArrayList\r\n    System.out.println(&quot;\\nArrayList obtained from Set: &quot; + numList); \r\n  } \r\n}\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>The given Set: [One, Two, Three]<br \/>\nArrayList obtained from Set: [One, Two, Three]<\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/9.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-122344\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/9.png\" alt=\"output\" width=\"408\" height=\"52\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/9.png 408w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/9-300x38.png 300w\" sizes=\"(max-width: 408px) 100vw, 408px\" \/><\/a><\/p>\n<p>In the above program, we iterate through the Set and each set element is added to the ArrayList.<\/p>\n<p><strong>#2) Using Constructor<\/strong><\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">import java.util.*; \r\n  \r\nclass Main { \r\n  public static void main(String&#x5B;] args) { \r\n    \/\/ Create a set of strings &amp; add elements to it \r\n    Set&lt;String&gt; set = new HashSet&lt;String&gt;(); \r\n    set.add(&quot;One&quot;); \r\n    set.add(&quot;Two&quot;); \r\n    set.add(&quot;Three&quot;); \r\n    \/\/print the set\r\n    System.out.println(&quot;The given Set: &quot; + set); \r\n    \/\/create an ArrayList and pass set to the constructor \r\n    List&lt;String&gt; numList = new ArrayList&lt;String&gt;(set); \r\n     \/\/print the ArrayList\r\n    System.out.println(&quot;\\nArrayList obtained from Set: &quot; + numList); \r\n  } \r\n}\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>The given Set: [One, Two, Three]<br \/>\nArrayList obtained from Set: [One, Two, Three]<\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/10.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-122345\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/10.png\" alt=\"output\" width=\"410\" height=\"52\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/10.png 410w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/10-300x38.png 300w\" sizes=\"(max-width: 410px) 100vw, 410px\" \/><\/a><\/p>\n<p>The above program creates a set and an ArrayList. The ArrayList object is created by providing a set object as an argument in its constructor.<\/p>\n<p><strong>#3) Using The addAll Method<\/strong><\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">import java.util.*; \r\n  \r\nclass Main { \r\n  public static void main(String&#x5B;] args) {   \r\n    \/\/ Create a set of strings &amp; add elements to it \r\n    Set&lt;String&gt; set = new HashSet&lt;String&gt;(); \r\n    set.add(&quot;One&quot;); \r\n    set.add(&quot;Two&quot;); \r\n    set.add(&quot;Three&quot;); \r\n    \/\/print the set\r\n    System.out.println(&quot;The given Set: &quot; + set); \r\n    \/\/create an ArrayList \r\n    List&lt;String&gt; numList = new ArrayList&lt;String&gt;(); \r\n    \/\/use addAll method of ArrayList to add elements of set \r\n    numList.addAll(set); \r\n    \/\/print the ArrayList\r\n    System.out.println(&quot;\\nArrayList obtained from Set: &quot; + numList); \r\n  } \r\n}\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>The given Set: [One, Two, Three]<br \/>\nArrayList obtained from Set: [One, Two, Three]<\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/11.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-122346\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/11.png\" alt=\"output\" width=\"398\" height=\"66\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/11.png 398w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/11-300x50.png 300w\" sizes=\"(max-width: 398px) 100vw, 398px\" \/><\/a><\/p>\n<p>Here, we use the addAll method of ArrayList to add the elements from the set to the ArrayList.<\/p>\n<p><strong>#4) Using Java 8 Stream<\/strong><\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">import java.util.*; \r\nimport java.util.stream.*; \r\nclass Main { \r\n  public static void main(String&#x5B;] args) { \r\n     \/\/ Create a set of strings &amp; add elements to it \r\n    Set&lt;String&gt; set = new HashSet&lt;String&gt;(); \r\n    set.add(&quot;One&quot;); \r\n    set.add(&quot;Two&quot;); \r\n    set.add(&quot;Three&quot;); \r\n    \/\/print the set\r\n    System.out.println(&quot;The given Set: &quot; + set); \r\n    \/\/create an ArrayList and using stream method,assign stream of elements to ArrayList\r\n    List&lt;String&gt; numList = set.stream().collect(Collectors.toList()); \r\n  \r\n    \/\/print the ArrayList\r\n    System.out.println(&quot;\\nArrayList obtained from Set: &quot; + numList); \r\n  } \r\n}\r\n<\/pre>\n<p><strong> Output:<\/strong><\/p>\n<p>The given Set: [One, Two, Three]<br \/>\nArrayList obtained from Set: [One, Two, Three]<\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/12.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-122347\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/12.png\" alt=\"output\" width=\"400\" height=\"56\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/12.png 400w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/12-300x42.png 300w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><\/p>\n<p>The above program uses stream class to convert Set to ArrayList.<\/p>\n<h3>An Array Of ArrayList In Java<\/h3>\n<p>An Array of ArrayList as the name suggests consists of ArrayLists as its elements. Though the feature is not used regularly, it is used when efficient usage of memory space is a requirement.<\/p>\n<p><strong>The following program implements an Array of ArrayLists in Java.<\/strong><\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">import java.util.ArrayList;\r\nimport java.util.List;\r\n\r\npublic class Main {\r\n\tpublic static void main(String&#x5B;] args) {\r\n\t\t\/\/define and initialize a num_list\r\n\t\tList&lt;String&gt; num_list = new ArrayList&lt;&gt;();\r\n\t\tnum_list.add(&quot;One&quot;);\r\n\t\tnum_list.add(&quot;Two&quot;);\r\n\t\tnum_list.add(&quot;Two&quot;);\r\n    \t\t\/\/define and initialize a colors_list\r\n\t\tList&lt;String&gt; colors_list = new ArrayList&lt;&gt;();\r\n\t\tcolors_list.add(&quot;Red&quot;);\r\n\t\tcolors_list.add(&quot;Green&quot;);\r\n\t\tcolors_list.add(&quot;Blue&quot;);\r\n\r\n        \t\t\/\/define Array of ArrayList with two elements\r\n\t\tList&lt;String&gt;&#x5B;] arrayOfArrayList = new List&#x5B;2];\r\n\t\t\/\/add num_list as first element \r\n\t\tarrayOfArrayList&#x5B;0] = num_list;\r\n\t\t\/\/add colors_list as second element\r\n\t\tarrayOfArrayList&#x5B;1] = colors_list;\r\n        \t\t\/\/print the contents of Array of ArrayList\r\n        \t\tSystem.out.println(&quot;Contents of Array of ArrayList:&quot;);\r\n\t\tfor (int i = 0; i &lt; arrayOfArrayList.length; i++) {\r\n\t\t\tList&lt;String&gt; list_str = arrayOfArrayList&#x5B;i];\r\n\t\t\tSystem.out.println(list_str);\r\n\t}\r\n}\r\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>Contents of Array of ArrayList:<br \/>\n[One, Two, Two]<br \/>\n[Red, Green, Blue]<\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/13.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-122348\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/13.png\" alt=\"output\" width=\"272\" height=\"80\" \/><\/a><\/p>\n<p>In the above program, we first define two lists. Then we declare an Array of two ArrayList. Each element of this array is the ArrayList defined earlier. Finally, the contents of an Array of ArrayList is displayed using a for loop.<\/p>\n<h3>ArrayList Of Arrays In Java<\/h3>\n<p>Just as we have an Array of ArrayLists, we can also have ArrayList of Arrays. Here, each individual element of an ArrayList is an Array.<\/p>\n<p><strong>The below program demonstrates ArrayList of Arrays.<\/strong><\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">import java.util.*;\r\n\r\npublic class Main {\r\n\tpublic static void main(String&#x5B;] args) {\r\n\t\t\/\/ declare ArrayList of String arrays\r\n\t\tArrayList&lt;String&#x5B;]&gt; ArrayList_Of_Arrays = new ArrayList&lt;String&#x5B;]&gt;();\r\n\t\t\/\/define individual string arrays\r\n\t\tString&#x5B;] colors = { &quot;Red&quot;, &quot;Green&quot;, &quot;Blue&quot; };\r\n\t\tString&#x5B;] cities = { &quot;Pune&quot;, &quot;Mumbai&quot;, &quot;Delhi&quot;};\r\n\t\t\/\/add each array as element to ArrayList\r\n\t\tArrayList_Of_Arrays.add(colors);\r\n\t\tArrayList_Of_Arrays.add(cities);\r\n\t\t\/\/ print ArrayList of Arrays\r\n\t\tSystem.out.println(&quot;Contents of ArrayList of Arrays:&quot;);\r\n\t\tfor (String&#x5B;] strArr : ArrayList_Of_Arrays) {\r\n\t\t\tSystem.out.println(Arrays.toString(strArr));\r\n\t\t}\r\n\t}\r\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>Contents of ArrayList of Arrays:<br \/>\n[Red, Green, Blue]<br \/>\n[Pune, Mumbai, Delhi]<\/p>\n<p><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/14.1.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-122353\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2020\/03\/14.1.png\" alt=\"output\" width=\"286\" height=\"93\" \/><\/a><\/p>\n<p>The above program demonstrates ArrayList of Arrays. Initially, we declare an ArrayList of String Arrays. This means each element of ArrayList will be a String Array. Next, we define two string Arrays. Then each of the Arrays is added to the ArrayList. Finally, we print the contents of ArrayList of Arrays.<\/p>\n<p>To print the contents, we traverse the ArrayList using for loop. For each iteration, we print the contents of the ArrayList element which has an Array using Arrays.toString () method.<\/p>\n<h3>List Vs ArrayList In Java<\/h3>\n<p><strong>The following tables show some of the differences between a List and ArrayList.<\/strong><\/p>\n\n<table id=\"tablepress-1266\" class=\"tablepress tablepress-id-1266\">\n<thead>\n<tr class=\"row-1\">\n\t<th class=\"column-1\">List<\/th><th class=\"column-2\">ArrayList<\/th>\n<\/tr>\n<\/thead>\n<tbody class=\"row-striping row-hover\">\n<tr class=\"row-2\">\n\t<td class=\"column-1\">The list is an interface in Java<\/td><td class=\"column-2\">ArrayList is a part of the Java Collection framework<\/td>\n<\/tr>\n<tr class=\"row-3\">\n\t<td class=\"column-1\">The list is implemented as an interface<\/td><td class=\"column-2\">ArrayList is implemented as a collection class <\/td>\n<\/tr>\n<tr class=\"row-4\">\n\t<td class=\"column-1\">Extends Collection Interface<\/td><td class=\"column-2\">implements List interface &amp; extends AbstractList<\/td>\n<\/tr>\n<tr class=\"row-5\">\n\t<td class=\"column-1\">Part of System.Collection.generic namespace<\/td><td class=\"column-2\">Part of System.Collections namespace<\/td>\n<\/tr>\n<tr class=\"row-6\">\n\t<td class=\"column-1\">Using List, a list of elements can be created which can be accessed using indices.<\/td><td class=\"column-2\">Using ArrayList, we can create a dynamic Array of elements or objects whose size automatically alters with the changes in contents.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n\n<h3>Vector Vs ArrayList<\/h3>\n<p><strong style=\"font-size: 16px;\">Given below are some of the differences between a Vector and an ArrayList.<\/strong><\/p>\n\n<table id=\"tablepress-1267\" class=\"tablepress tablepress-id-1267\">\n<thead>\n<tr class=\"row-1\">\n\t<th class=\"column-1\">ArrayList<\/th><th class=\"column-2\">LinkedList<\/th>\n<\/tr>\n<\/thead>\n<tbody class=\"row-striping row-hover\">\n<tr class=\"row-2\">\n\t<td class=\"column-1\">ArrayList implements List interface<\/td><td class=\"column-2\">LinkedList implements List and Deque interfaces.<\/td>\n<\/tr>\n<tr class=\"row-3\">\n\t<td class=\"column-1\">Data storage and access are efficient in ArrayList.<\/td><td class=\"column-2\">LinkedList is good at manipulating data.<\/td>\n<\/tr>\n<tr class=\"row-4\">\n\t<td class=\"column-1\">ArrayList internally implements a dynamic array.<\/td><td class=\"column-2\">LinkedList internally implements a doubly linked list.<\/td>\n<\/tr>\n<tr class=\"row-5\">\n\t<td class=\"column-1\">Since ArrayList internally implements dynamic array, the addition\/deletion of elements is slow as a lot of bit-shifting is required.<\/td><td class=\"column-2\">LinkedList is faster as far as addition\/removal of elements is concerned since no bit shifting is necessary.<\/td>\n<\/tr>\n<tr class=\"row-6\">\n\t<td class=\"column-1\">Less memory overhead since in ArrayList only actual data is stored.<\/td><td class=\"column-2\">More memory overhead since each node in LinkedList contains data as well as the address to the next node.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n\n<h3>ArrayList vs LinkedList<\/h3>\n<p><span style=\"font-size: 16px;\">Let us now discuss the various differences between an ArrayList and a LinkedList.<\/span><\/p>\n\n<table id=\"tablepress-1268\" class=\"tablepress tablepress-id-1268\">\n<thead>\n<tr class=\"row-1\">\n\t<th class=\"column-1\">ArrayList<\/th><th class=\"column-2\">LinkedList<\/th>\n<\/tr>\n<\/thead>\n<tbody class=\"row-striping row-hover\">\n<tr class=\"row-2\">\n\t<td class=\"column-1\">ArrayList implements List interface<\/td><td class=\"column-2\">LinkedList implements List and Deque interfaces.<\/td>\n<\/tr>\n<tr class=\"row-3\">\n\t<td class=\"column-1\">Data storage and access are efficient in ArrayList.<\/td><td class=\"column-2\">LinkedList is good at manipulating data.<\/td>\n<\/tr>\n<tr class=\"row-4\">\n\t<td class=\"column-1\">ArrayList internally implements a dynamic array.<\/td><td class=\"column-2\">LinkedList internally implements a doubly linked list.<\/td>\n<\/tr>\n<tr class=\"row-5\">\n\t<td class=\"column-1\">Since ArrayList internally implements dynamic array, the addition\/deletion of elements is slow as a lot of bit-shifting is required.<\/td><td class=\"column-2\">LinkedList is faster as far as addition\/removal of elements is concerned since no bit shifting is necessary.<\/td>\n<\/tr>\n<tr class=\"row-6\">\n\t<td class=\"column-1\">Less memory overhead since in ArrayList only actual data is stored.<\/td><td class=\"column-2\">More memory overhead since each node in LinkedList contains data as well as the address to the next node.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n\n<h3>Frequently Asked Questions<\/h3>\n<p><span style=\"color: #ff6600;\"><strong>Q #1) How do you convert an ArrayList to an Array in Java?<\/strong><\/span><\/p>\n<p><strong>Answer:<\/strong> To convert an ArrayList to an Array in Java, one can use the toArray ( ) method from ArrayList API that converts a given ArrayList to an Array.<\/p>\n<p><span style=\"color: #ff6600;\"><strong>Q #2<span style=\"color: #ff6600;\">) <\/span><\/strong><strong>How do you split a string and store it in an ArrayList in Java?<\/strong><\/span><\/p>\n<p><strong>Answer:<\/strong> The string is split using a split () function. This method returns an Array of strings. Then using the Arrays.asList () method, the string array can be converted to an ArrayList of strings.<\/p>\n<p><span style=\"color: #ff6600;\"><strong>Q #3) What is the default size of an ArrayList?<\/strong><\/span><\/p>\n<p><strong>Answer:<\/strong> An ArrayList object created without specifying the capacity has a size 0 as there are no elements added to the list. But the default capacity of this ArrayList is 10.<\/p>\n<p><span style=\"color: #ff6600;\"><strong>Q #4) What is the difference between length () and size () of ArrayList?<\/strong><\/span><\/p>\n<p><strong>Answer:\u00a0<\/strong>An ArrayList does not have a length () property or method. It provides only the size () method that returns the total number of elements in the ArrayList.<\/p>\n<p><span style=\"color: #ff6600;\"><strong>Q #5) What is the difference between the capacity and size of ArrayList?<\/strong><\/span><\/p>\n<p><strong>Answer:<\/strong> ArrayList possesses both capacity and size. Capacity is the total size of the ArrayList or the total number of elements it can hold. Size is the number of elements or locations that have data in them.<\/p>\n<p><strong><span style=\"text-decoration: underline;\">For example,<\/span><\/strong> if ArrayList capacity is 10 and its size is 5, this means that an ArrayList can hold up to 10 elements, but at present only 5 locations have data in them.<\/p>\n<h3>Conclusion<\/h3>\n<p>In this tutorial, we discussed some of the additional concepts related to ArrayList like converting ArrayList to a string, list, set, and vice versa. We also discussed the differences between ArrayList and Vector, ArrayList and LinkedList, etc.<\/p>\n<p><em><strong>In our upcoming tutorial, we will take up another collection and learn it thoroughly.<\/strong><\/em><\/p>\n<p><strong>=&gt; <a href=\"https:\/\/www.softwaretestinghelp.com\/java\/\">Check Here To See A-Z Of Java Training Tutorials Here.<\/a><\/strong><\/p>\n\r\n\t\t\t<div id=\"daexthefup-container\"\r\n\t\t\t\tclass=\"daexthefup-container daexthefup-layout-stacked daexthefup-alignment-center\"\r\n\t\t\t\tdata-post-id=\"122313\">\r\n\r\n\t\t\t\t<div class=\"daexthefup-feedback\">\r\n\t\t\t\t\t<div class=\"daexthefup-text\">\r\n\t\t\t\t\t\t<h3 class=\"daexthefup-title\">Was this helpful?<\/h3>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<div class=\"daexthefup-buttons-container\">\r\n\t\t\t\t\t\t<div class=\"daexthefup-buttons\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t<div class=\"daexthefup-yes daexthefup-button daexthefup-button-type-icon\" data-value=\"1\">\r\n\t\t\t\t\r\n                <svg>\r\n                    <defs>\r\n                        <style>.thumb-up-cls-1{fill:#c9c9c9;}.thumb-up-cls-2{fill:#e1e1e1;}.thumb-up-cls-3{fill:#676767;}<\/style>\r\n                    <\/defs>\r\n                    <g id=\"thumb_up\">\r\n                        <path class=\"thumb-up-cls-2 daexthefup-icon-circle\" d=\"m24,3c11.58,0,21,9.42,21,21s-9.42,21-21,21S3,35.58,3,24,12.42,3,24,3m0-1C11.85,2,2,11.85,2,24s9.85,22,22,22,22-9.85,22-22S36.15,2,24,2h0Z\" \/>\r\n                        <g>\r\n                            <rect class=\"thumb-up-cls-3 daexthefup-icon-secondary-color\" x=\"10\" y=\"20\" width=\"6\" height=\"15\" rx=\"1.5\" ry=\"1.5\" \/>\r\n                            <path class=\"thumb-up-cls-1 daexthefup-icon-primary-color\" d=\"m30.57,9.06l-.49-.1c-.81-.17-1.61.35-1.78,1.16l-5.3,11.74c-.17.81,3.16,1.61,3.97,1.78l1.96.41c.81.17,1.61-.35,1.78-1.16l2.18-10.27c.34-1.61-.7-3.21-2.31-3.56Z\" \/>\r\n                            <path class=\"thumb-up-cls-1 daexthefup-icon-primary-color\" d=\"m38.17,20h-18.67c-.83,0-1.5.67-1.5,1.5v12c0,.83.67,1.5,1.5,1.5h16.27c.71,0,1.33-.5,1.47-1.21l2.4-12c.19-.93-.53-1.8-1.47-1.8Z\" \/>\r\n                        <\/g>\r\n                    <\/g>\r\n                <\/svg>\t\t\t<\/div>\r\n\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t<div class=\"daexthefup-no daexthefup-button daexthefup-button-type-icon\" data-value=\"0\">\r\n\t\t\t\t\r\n                <svg>\r\n                    <defs>\r\n                        <style>.thumb-down-cls-1{fill:#c9c9c9;}.thumb-down-cls-2{fill:#e1e1e1;}.thumb-down-cls-3{fill:#676767;}<\/style>\r\n                    <\/defs>\r\n                    <g id=\"thumb_down\">\r\n                        <path class=\"thumb-down-cls-2 daexthefup-icon-circle\" d=\"m24,3c11.58,0,21,9.42,21,21s-9.42,21-21,21S3,35.58,3,24,12.42,3,24,3m0-1C11.85,2,2,11.85,2,24s9.85,22,22,22,22-9.85,22-22S36.15,2,24,2h0Z\" \/>\r\n                        <g>\r\n                            <rect class=\"thumb-down-cls-3 daexthefup-icon-secondary-color\" x=\"10\" y=\"13\" width=\"6\" height=\"15\" rx=\"1.5\" ry=\"1.5\" \/>\r\n                            <path class=\"thumb-down-cls-1 daexthefup-icon-primary-color\" d=\"m30.57,38.94l-.49.1c-.81.17-1.61-.35-1.78-1.16l-5.3-11.74c-.17-.81,3.16-1.61,3.97-1.78l1.96-.41c.81-.17,1.61.35,1.78,1.16l2.18,10.27c.34,1.61-.7,3.21-2.31,3.56Z\" \/>\r\n                            <path class=\"thumb-down-cls-1 daexthefup-icon-primary-color\" d=\"m38.17,28h-18.67c-.83,0-1.5-.67-1.5-1.5v-12c0-.83.67-1.5,1.5-1.5h16.27c.71,0,1.33.5,1.47,1.21l2.4,12c.19.93-.53,1.8-1.47,1.8Z\" \/>\r\n                        <\/g>\r\n                    <\/g>\r\n                <\/svg>\t\t\t<\/div>\r\n\r\n\t\t\t\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t<\/div>\r\n\r\n\t\t\t\t<div class=\"daexthefup-comment\">\r\n\t\t\t\t\t<div class=\"daexthefup-comment-top-container\">\r\n\t\t\t\t\t\t<label id=\"daexthefup-comment-label\" class=\"daexthefup-comment-label\"><\/label>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"daexthefup-comment-character-counter-container\">\r\n\t\t\t\t\t\t\t\t<div id=\"daexthefup-comment-character-counter-number\"\r\n\t\t\t\t\t\t\t\t\tclass=\"daexthefup-comment-character-counter-number\"><\/div>\r\n\t\t\t\t\t\t\t\t<div class=\"daexthefup-comment-character-counter-text\"><\/div>\r\n\t\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<textarea id=\"daexthefup-comment-textarea\" class=\"daexthefup-comment-textarea\"\r\n\t\t\t\t\t\t\t\tplaceholder=\"Type your message\"\r\n\t\t\t\t\t\t\t\tmaxlength=\"\r\n\t\t\t\t\t\t\t\t400\t\t\t\t\t\t\t\t\t\"><\/textarea>\r\n\t\t\t\t\t<div class=\"daexthefup-comment-buttons-container\">\r\n\t\t\t\t\t\t<button class=\"daexthefup-comment-submit daexthefup-button\">Submit<\/button>\r\n\t\t\t\t\t\t<button class=\"daexthefup-comment-cancel daexthefup-button\">Cancel<\/button>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t<\/div>\r\n\r\n\t\t\t\t<div class=\"daexthefup-successful-submission-text\">Thanks for your feedback!<\/div>\r\n\r\n\t\t\t<\/div>\r\n\r\n\t\t\t","protected":false},"excerpt":{"rendered":"<p>This Tutorial Discusses ArrayList Conversions to other Collections like Set, LinkedList, Lists, etc. along with Differences Between These Collections: So far we have seen almost all the concepts related to ArrayList in Java. Apart from creating and manipulating ArrayList using various operations or methods provided by ArrayList class, sometimes it &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Java ArrayList Conversions To Other Collections\" class=\"read-more button\" href=\"https:\/\/www.softwaretestinghelp.com\/java-arraylist-conversions\/#more-122313\" aria-label=\"Read more about Java ArrayList Conversions To Other Collections\">Read more<\/a><\/p>\n","protected":false},"author":9,"featured_media":122669,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_helpful_pro_status":1,"footnotes":""},"categories":[408],"tags":[],"class_list":{"0":"post-122313","1":"page","2":"type-page","3":"status-publish","4":"has-post-thumbnail","6":"category-java"},"acf":[],"_links":{"self":[{"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/pages\/122313","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/comments?post=122313"}],"version-history":[{"count":0,"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/pages\/122313\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/media\/122669"}],"wp:attachment":[{"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/media?parent=122313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/categories?post=122313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/tags?post=122313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}