【发布时间】:2018-08-29 11:58:41
【问题描述】:
我有一个linkedhashmap,它有字符串值和几个其他链接hashmap的集合。
我需要获取所有值。
这是我的代码:
HashMap<String, String> lhm = new HashMap<String, String>();
//********Code to assign lhm *******
System.out.println("LHM="+lhm.values());
输出:
LHM=[{SchemaVersion=1.0, AgentVersion=3.0.1.31, ServiceTag=XXXX, Model=Latitude E7240, Registered=true, OSVersion=10.0.14393, SPVersion=0, UTCDate=2018-08-28T17:38:57.5935378Z, BIOSVersion=A25, Status=Informational, Description=No Failures detected; High Memory Usage; High CPU Usage}, {LocalDate=2018-08-28T23:08:57.6080352+05:30, LastBootUpDate=2018-08-28T23:05:36.48659, WindowsUpdatedRunDate=0001-01-01T00:00:00, ApplicationCrashesLast24hrs=0, SystemDriveFreeSpace=202.30 GB, HighMemUsage=82.8125, HighCPUUsage=100}, XXXXXX$$2313213132132131233]
【问题讨论】:
-
“我需要获取所有值”是什么意思?你刚刚使用
lhm.values() -
一个定义为
<String, String>的Map不能是“多级”它只能存储String值 -
@Sharon Ben Ashe,我需要将各个值分配给变量。
-
的 map 可以代替什么解决方案? -
我注意到你的问题仍然是“开放的”——因为你没有接受答案。请查看并决定是否要accept 回答。或者让我知道我是否可以做些什么来增强我的输入以使其被接受。接受有助于未来的读者确定问题是否已解决,并对花时间回答你的人表示感谢。谢谢!