给定一个键,如何显示存储为值的ArrayList?

Jon*_*ony 1 java hashmap

我有一个hashmap,每个键都有很多值(存储在arraylist中).如何显示arraylist,即java中hashmap中特定键的值?

Osc*_*Ryz 6

import java.util.*;

public class PrintListFromHashMap {

    public static void main( String [] args ) {

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

        hashMap.put( "list",       new ArrayList<String>(Arrays.asList("A","B","C")));

        System.out.println( hashMap.get("list") );

    }

}

$ javac PrintListFromHashMap.java 
$ java PrintListFromHashMap
[A, B, C]
Run Code Online (Sandbox Code Playgroud)