Background: When you use a Map object, you may have a key that corresponds to the need for multiple values
Realize:
Import Java.util.arraylist;import java.util.hashmap;import Java.util.list;import Java.util.map;import Java.util.map.entry;public class Test2 {public static void main (string[] args) {map<integer,list<string>> Levelmap=new hashmap<integer,list<string>> (); List<string> putlist=new arraylist<> (); Putlist.add ("Multiple values 1"); Putlist.add ("Multiple Values 2"); Putlist.add ("Multiple Values 3"); for (int i=0;i<5;i++) {levelmap.put (I, putlist);} Prints the value of the Levemap for (Entry<integer, list<string>> in:levelmap.entrySet ()) {System.out.println ("key=== "+in.getkey () +" values= "+in.getvalue ());}}
Show
If you want to print values in a single, you can continue to traverse values.
Java uses HashMap a key to multi-valued method