How to Convert all LinkedHashMap Values to a List in Java? Last Updated : 19 Sep, 2022 Comments Improve Suggest changes Like Article Like Report 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 using the values() method. The values() method of the LinkedHashMap class returns a Collection view of all the values contained in the map object. You can then use this collection to convert it to a List object. Syntax: LinkedHashMap.values() Return Value: The method is used to return a collection view containing all the values of the map. Example 1: Java // Java program to Convert all LinkedHashMap values to a // List import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; public class LinkedHashMapToListExample { public static void main(String[] args) { // instance of linkedhashmap LinkedHashMap<Integer, Integer> lhmap = new LinkedHashMap<Integer, Integer>(); // add mappings lhmap.put(1, 11); lhmap.put(2, 22); lhmap.put(3, 33); // convert values to a list List<Integer> listValues = new ArrayList<Integer>(lhmap.values()); // print values System.out.println("List contains:"); for (Integer value : listValues) { System.out.println(value); } } } OutputList contains: 11 22 33 Example 2: Java // Java program to Convert all LinkedHashMap values to a // List import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; public class LinkedHashMapToListExample { public static void main(String[] args) { // instance of linkedhashmap LinkedHashMap<Integer, String> lhmap = new LinkedHashMap<Integer, String>(); // add mappings lhmap.put(10, "Geeks"); lhmap.put(15, "4"); lhmap.put(20, "Geeks"); lhmap.put(25, "Welcomes"); lhmap.put(30, "You"); // convert values to a list List<String> listValues = new ArrayList<String>(lhmap.values()); // print values System.out.println("List contains:"); for (String value : listValues) { System.out.println(value); } } } OutputList contains: Geeks 4 Geeks Welcomes You Another Method : Using List.copyOf() In java, we can convert the set to list by using List.copyOf(object). For this, we have to import the package java.util.List.*. It is a static factory method which creates the list object from another collection or object. Java import java.util.*; class GFG { public static void main (String[] args) { LinkedHashMap<Integer, String> lhmap = new LinkedHashMap<Integer, String>(); // add mappings lhmap.put(10, "Geeks"); lhmap.put(15, "4"); lhmap.put(20, "Geeks"); lhmap.put(25, "Welcomes"); lhmap.put(30, "You"); // convert values to a list List<String> listValues = List.copyOf(lhmap.values()); // print values System.out.println("List contains:"); for (String value : listValues) { System.out.println(value); } } } OutputList contains: Geeks 4 Geeks Welcomes You Comment More infoAdvertise with us Next Article How to Convert all LinkedHashMap Values to a List in Java? K kaaruni1124 Follow Improve Article Tags : Java Technical Scripter Java Programs Technical Scripter 2020 java-list Java-LinkedHashMap +2 More Practice Tags : Java Similar Reads 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 Get All the Values of the LinkedHashMap in Java? LinkedHashMap is a predefined class in Java that is similar to HashMap, contains key and its respective value, unlike HashMap. In LinkedHashMap insertion order is preserved. The task is to get all the values present in our LinkedHashMap that is linked with their respective key. Use Iteration or pred 4 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 Add Key-Value pairs to LinkedHashMap in Java? LinkedHashMap is a Hash table and linked list implementation of the Map interface. In LinkedHashMap order of key-value pair depends on the order in which keys were inserted into the map. Insertion order does not affect if a key is reinserted into the map. Example: Input: Key: 1 Value : 1221 Key: 2 V 2 min read How to Check if LinkedHashMap Contains a value in Java? LinkedHashMap is a predefined class in Java which is similar to HashMap, contains key and its respective value unlike HashMap, In LinkedHashMap insertion order is preserved. The task is to check if LinkedHashMap contains any value in java. to check we have to iterate through our LinkedHashMap and if 3 min read How to Get a Value From LinkedHashMap by Index in Java? LinkedHashMap is a predefined class in Java which is similar to HashMap, contain key and its respective value unlike HashMap, In LinkedHashMap insertion order is preserved. The task is to get value from LinkedHashMap by their Index in other words, an order of their insertion. As an advantage of Link 4 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 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 How to Update the Value of an Existing Key in a LinkedHashMap in Java? In Java programming, a LinkedHahMap is like HashMap with additional features in the Java Collections framework. It keeps track of the order in which elements were added. A regular HashMap doesn't have a fixed order for elements. LinkedHashMap uses an approach with a doubly-linked list to remember th 3 min read How to Print all Keys of the LinkedHashMap in Java? LinkedHashMap is a predefined class in Java that is similar to HashMap, contains a key and its respective value. Unlike HashMap, In LinkedHashMap insertion order is preserved. The task is to print all the Keys present in our LinkedHashMap in java. We have to iterate through each Key in our LinkedHas 2 min read Like