Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个Map类型变量
Map
a = new HashMap<String, ArrayList<String>>();
我的问题是:
例如,现在我有String b, String c,如何使用put()方法将其放入地图?我不知道如何写表达式。
String b, String c
put()
如果我只想输入一个键,例如String d,并且不向值集添加任何字符串,如何编写?
String d
谢谢!
你可以尝试这样的事情。
Map<String, List<Integer>> a = new HashMap<String, List<Integer>>(); Integer i = 100; //say String b = "str"; //say List<Integer> list = new ArrayList<Integer>(); list.add(i); a.put(b,list);