Convert Array to LinkedList in Java Last Updated : 31 Mar, 2022 Comments Improve Suggest changes Like Article Like Report Array is contiguous memory allocation while LinkedList is a block of elements randomly placed in the memory which are linked together where a block is holding the address of another block in memory. Sometimes as per requirement or because of space issues in memory where there are bigger chunks of code in the enterprising world it becomes necessary to convert arrays to List. Here conversion of array to LinkedList is demonstrated. Methods: Using asList() method of Collections classUsing addAll() method of Collections class Method 1: Using asList() method of Collections class This method acts as bridge between array-based and collection-based APIs, in combination with Collection.toArray(). The returned list is serialized and implements RandomAccess. This runs in O(1) time. Syntax: public static List asList(T... a) ; Parameters: This method takes the array a which is required to be converted into a List. Here array of parameters works similar to an object array parameter. Approach: Create an array.Convert the array to List.Create LinkedList from the List using the constructor. Example Java // Java Program to convert Array to LinkedList // Importing array, List & LinkedList classes from // java.util package import java.util.Arrays; import java.util.LinkedList; import java.util.List; // Class public class GFG { // Main driver method public static void main(String[] args) { // Create a string Array String[] strArr = { "A", "B", "C", "D", "E" }; // Convert array to list List<String> list = Arrays.asList(strArr); // Create a LinkedList and // pass List in LinkedList constructor LinkedList<String> linkedList = new LinkedList<String>(list); // Display and print all elements of LinkedList System.out.println("LinkedList of above array : " + linkedList); } } OutputLinkedList of above array : [A, B, C, D, E] Method 2: Using addAll() method of Collections class This method is used to append all the elements from the collection passed as parameter to this function to the end of a list keeping in mind the order of return by the collections iterator. Syntax: boolean addAll(Collection C) ; Parameters: The parameter C is a collection of ArrayList. It is the collection whose elements are needed to be appended at the end of the list. Return Value: The method returns true if at least one action of append is performed else return false. Approach: Create an array.Create an empty LinkedList.Use addAll() method of collections class which takes two objects as parameters.First object as where to be convertedSecond object as which to be converted. Example Java // Java Program to convert Array to LinkedList // Importing array, List & LinkedList, Collections classes // from java.util package import java.util.Arrays; import java.util.Collections; import java.util.LinkedList; import java.util.List; // Class public class GFG { // Main driver method public static void main(String[] args) { // Create an Array // here string type String[] strArr = { "G", "E", "E", "K", "S" }; // Create an empty LinkedList LinkedList<String> linkedList = new LinkedList<String>(); // Append all elements of array to linked list // using Collections.addAll() method Collections.addAll(linkedList, strArr); // Print the above LinkedList received System.out.println("Converted LinkedList : "+linkedList); } } OutputConverted LinkedList : [G, E, E, K, S] Comment More infoAdvertise with us Next Article Convert Array to LinkedList in Java mukulsomukesh Follow Improve Article Tags : Java Technical Scripter Java Programs Technical Scripter 2020 Java-Collections Java-Arrays java-LinkedList +3 More Practice Tags : JavaJava-Collections Similar Reads Convert a HashSet to a LinkedList in Java In Java, HashSet and LinkedList are linear data structures. These are majorly used in many cases. There may be some cases where we need to convert HashSet to LinkedList. So, in this article, we will see how to convert HashSet to LinkedList in Java. Java Program to Convert a HashSet to a LinkedList T 2 min read Convert HashMap to LinkedList in Java HashMap is similar to the HashTable, but it is unsynchronized. It allows to store the null keys as well, but there should be only one null key object and there can be any number of null values. LinkedList is a part of the Collection framework present in java.util package. This class is an implementa 2 min read How to Convert ArrayList to LinkedHashSet in Java? ArrayList is a data structure that overcomes the shortcomings of the common array in Java wherein the size has to be explicitly specified beforehand. The length of the array data structure cannot be modified which is taken care of the ArrayList data structure. This data structure is also known as th 8 min read How to Sort a LinkedList in Java? A Linked List is a linear data structure, in which the elements are not stored at contiguous memory locations.Sorting the nodes of a Singly Linked list in ascending order:Original ListSorted ListWe can sort the LinkedList by many sorting techniques:Selection SortInsertion sortQuick sortMerge sort Me 13 min read How to Convert LinkedHashMap to List in Java? LinkedHashMap is predefined class in Java which is similar to HashMap, contains key and its respective value unlike HashMap, in LinkedHashMap insertion order is preserved. We to convert LinkedHashMap to ArrayList. A Map store data in pair of Key and Value while converting a LinkedHashMAp to ArrayLis 2 min read How to Convert a LinkedHashSet into an Array and List in Java? In Java, LinkedHashSet is a predefined class of Java that extends the HashSet and it implements the Set interface. It can be used to implement the doubly linked list of the elements in the set, and it provides the predictable iteration order. In this article, we will learn how to convert a LinkedHas 3 min read Java Program to Convert an Array into a List In Java, arrays and lists are two commonly used data structures. While arrays have a fixed size and are simple to use, lists are dynamic and provide more flexibility. There are times when you may need to convert an array into a list, for instance, when you want to perform operations like adding or r 4 min read How to Convert all LinkedHashMap Values to a List in Java? The task is to convert all LinkedHashMap values to a list in java. LinkedHashMap is an implementation of a Map. The Map and List are two different data structures. The Map stores key-value pairs while the List is an ordered collection of elements. To convert all values of the LinkedHashMap to a List 2 min read How to Implement Generic LinkedList in Java? Linked List is Linear Data Structures that store values in nodes. As we do know here each Node possesses two properties namely the value of the node and link to the next node if present so. Linked List can not only be of Integer data type but String, boolean, Float, Character, etc. We can implement 8 min read Conversion of a List to a Queue in Java In this article, We will learn about how to convert a List to a Queue in Java using various methods. PrerequisiteQueue Interface in JavaList Interface in JavaMethods to Convert List to Queue in JavaIn Java, there are a few ways to convert a List to a Queue. Here are some methods and ways you can ach 3 min read Like