You need to iterate over your list, here is an example

public static void main(String[] args){
    List<LinkedHashMap<String,String>> list = new ArrayList<LinkedHashMap<String, String>>();

    LinkedHashMap<String, String> test = new LinkedHashMap<String, String>();
        test.put("a","1");
        test.put("b","2");

    list.add(test);

    for(Map<String, String> map : list){
        for(String key : map.keySet()){
            System.out.println("key: " + key + " value " + map.get(key));
        }
    }

}
Answer from Patrick M on Stack Overflow
🌐
Quora
quora.com › How-do-I-add-a-key-value-pair-in-ArrayList-in-Java
How to add a key value pair in ArrayList in Java - Quora
Answer (1 of 4): We can’t directly store key value pair. But we can achieve it through creating an ArrayList of user defined class, having two instance variables say key, value. Please refer the below example for understanding better - Otherwise, Hashmap, LinkedHashMap, TreeMap are the the data...
🌐
Sololearn
sololearn.com › en › Discuss › 1544296 › how-can-get-the-key-of-value-in-arraylist
How can get the key of value in arraylist? | Sololearn: Learn to code for FREE!
October 14, 2018 - I have a teacher class Teacher has name and code. Arraylist<Teacher> teachers; Teacher t = new Teacher(); t.add(“teacher1”, 100); teachers.add(t); String name =teachers.get(teachers.IndexOf(100)).getName(); //this do not return name of teacher. Why · Learn more efficiently, for free:
🌐
Java Made Easy!
java-made-easy.com › java-collections.html
Java Collections - ArrayList and HashMap
Then, that array is stored in an array called keys. The reason I'm creating an array of Strings is because the keys are all Strings from before. How are hash maps useful? They let you store objects by looking up other objects instead of index values like you would with an ArrayList.
🌐
Blogger
javahungry.blogspot.com › 2020 › 06 › hashmap-to-arraylist.html
Convert HashMap to ArrayList in Java | Java Hungry
In Java 8, we can use below two methods to convert HashMap into ArrayList: 1. Conversion of HashMap Keys to ArrayList · import java.util.*; import java.util.Map.Entry; import java.util.stream.Collectors; public class JavaHungry { public static void main(String args[]) { //Creating a HashMap Object HashMap<Integer,Integer> map = new HashMap<>(); //Adding Values to HashMap map.put(1,10); map.put(2,20); map.put(3,30); map.put(4,40); map.put(5,50); //Creating an ArrayList Object and adding HashMap keys to it using Java 8 ArrayList<Integer> list = (ArrayList<Integer>)map.keySet().stream().collect(Collectors.toList()); System.out.println("ArrayList of Keys: "); //Displaying the contents of ArrayList of keys in Java 8 list.forEach(System.out::println); } } Output: ArrayList of Keys: 1 2 3 4 5 2.
🌐
Baeldung
baeldung.com › home › java › java collections › java map › get values and keys as arraylist from a hashmap
Get Values and Keys as ArrayList From a HashMap | Baeldung
March 7, 2025 - List<String> keyList = new ArrayList<>(); List<String> valueList = new ArrayList<>(); for (Map.Entry<String, String> entry : DEV_MAP.entrySet()) { keyList.add(entry.getKey()); valueList.add(entry.getValue()); } assertKeyAndValueList(keyList, valueList); The test passes if we give it a run. So this approach does the job. If we work with Java 8 or later, we can replace the for loop with the forEach() call and a lambda expression to improve the code’s readability:
🌐
Coderanch
coderanch.com › t › 568613 › java › Adding-key-pairs-HashMap-ArrayList
Adding key/value pairs from a HashMap in to an ArrayList (Beginning Java forum at Coderanch)
February 26, 2012 - For the desired output we can assume that the productAttribute parameter value is "Computer". Current output of the addProduct ArrayList: Desired output of the addProduct ArrayList: I can't seem to figure out what I'm doing wrong. Any help would be greatly appreciated. ... So you have a map which maps a String to a list of Strings. And if I understand your example right, you want to mutate that into a list of lists of Strings, where each of the inner lists comprises a key of the map followed by the list it's mapped to?
🌐
GeeksforGeeks
geeksforgeeks.org › java › difference-between-arraylist-and-hashmap-in-java
Difference Between ArrayList and HashMap in Java - GeeksforGeeks
July 11, 2025 - ArrayList is a part of the collection framework and is present in java.util package. It provides us with dynamic arrays in Java. Though, it may be slower than standard arrays but can be helpful in programs where lots of manipulation in the array is needed. HashMap is a part of Java's collection since Java 1.2. It provides the basic implementation of the Map interface of Java. It stores the data in (Key, Value) pairs, and in order to access a value, one must know its key.
Find elsewhere
🌐
LinkedIn
linkedin.com › pulse › mastering-java-collections-arraylist-hashmap-more-1c
Mastering Java Collections: ArrayList, HashMap, and More
August 8, 2023 - Collections provide essential data structures and algorithms for managing and manipulating groups of objects. In this guide, we'll delve into some of the most commonly used Java collections: ArrayList and HashMap. These collections offer dynamic arrays and key-value mappings, respectively, and are part of the Java Collections Framework.
🌐
Educative
educative.io › answers › how-to-convert-a-hashmap-to-an-arraylist
How to convert a HashMap to an ArrayList
HashMap is a collection class, based on Maps, that stores key and value pairs; they are denoted as HashMap<Key, Value> or HashMap<K, V>. ArrayList provides the dynamic arrays in Java.
🌐
Real's HowTo
rgagnon.com › javadetails › java-0564.html
Get keys corresponding to a value from a Map - Real's Java How-to
Got it This method returns a List of the keys corresponding to a given value. ... import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class MapUtils { private MapUtils() {} public static ...
🌐
Coderanch
coderanch.com › t › 370276 › java › key-values-arraylist
how to get the key values from a arraylist (Java in General forum at Coderanch)
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums · this forum made possible by our volunteer staff, including ... ... hello everyone i hope someone can help me i have this arraylist called arr arr.add(1, "ben"); how would i get the number one out of it?
🌐
GeeksforGeeks
geeksforgeeks.org › java › how-to-convert-hashmap-to-arraylist-in-java
How to Convert HashMap to ArrayList in Java? - GeeksforGeeks
July 15, 2025 - If we need an ArrayList containing only the keys from the HashMap, we can use the keySet() method in the HashMap and convert it to an ArrayList. Example: This example demonstrates how to extract the keys of a HashMap and store them in an ArrayList.
🌐
Java Code Geeks
examples.javacodegeeks.com › home › java development › core java
Get ArrayLists of Values and Keys from a HashMap in Java - Java Code Geeks
October 27, 2023 - The result is an ArrayList containing the keys from the HashMap as shown in Fig 1 below: ... The code snippet below shows how we can convert the values of a HashMap into an ArrayList using Java 8 Streams.
Top answer
1 of 2
2

I guess thats what you want to do

Map<String, List<String>> map = new HashMap<String, List<String>>();
// ...some more code...
for (List<String> regexNumbers : map.values()) {
    // regexNumbers is the value
}

Since you dont use the key in your method.

But your code whould be much more readable if you create a class - thats your structure, thats what you want, and you know (!) whats in it (even in a few years):

class CountryNumbers {
    String country;
    List<String> numbers;
}

Examplecode to print every number to a country:

List<CountryNumbers> list = fillListSomehow();
for (CountryNumbers countryNumbers : list) {
    String country = countryNumbers.country;
    System.out.println("The regexes for country " + country + " are: ");
    for (String regexNumber : countryNumbers.numbers) {
        System.out.println("  " + regexNumber);
    }
}
2 of 2
-1

Instead of

static Map <List<String>, String> data = new HashMap<List<String>, String>();

You should do

static Map <String, List<String>> data = new HashMap<String, List<String>>();

Then, down when you are trying to go through the values

void numberCheck (String inputNumber)
{


    String[] keys = (String[]) data.keySet().toArray();
for (int i = 0; i<= keys.length; i++)
{
    List<String> check = (List<String>)data.get(keys[i]);
    for (int j = 0; j <check.size(); j++)   
    {

        Pattern pat = Pattern.compile(check.get(j));
        Matcher matcher = pat.matcher(inputNumber);
        if (matcher.find())
        {
            // some useful code
        }

    }


}
}

It will actually return a List. By calling data.get(i) you are asking for the VALUE of the data set at index i in the Map.