Home » Posts tagged 'hashmap same key multiple values java'

Tag Archives: hashmap same key multiple values java

Newly Updated Posts

HashMap: Multiple Values under one key

In this tutorial learn how to put multiple values in single Key in HashMap.

Code:

package com.sanity.Methods;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class HashMapCode {
public static void main(String[] args) {
HashMap	map =new HashMap<String, List<String>>();
List<String> addValue= new ArrayList<>();
addValue.add("First");
addValue.add("Second");
addValue.add("Third");
addValue.add("Fourth");
addValue.add("Fifth");
addValue.add("Sixth");
map.put("Name", addValue);
		
System.out.println("All the Values under Name Key--------->"+addValue);
		
		
	}

}

Consider above code for adding multiple values in single key in hashmap

Further topics on selenium, navigate to link