我有一个服务器树状图:
TreeMap server_map = new TreeMap<String, Server>() ;我想遍历整个地图来打印所有的服务器。使用这种循环:
for (Map.Entry<String, Server> entry : server_map.entrySet())
{
System.out.println(entry.getKey() + "/" + entry.getValue().foo);
}这是行不通的,因为有一个未解决的编译问题:
类型不匹配:无法从元素类型对象转换为Map.Entry
难道没有可能在服务器的树状图上迭代吗?
发布于 2013-06-10 00:44:20
将声明更改为:
TreeMap<String, Server> server_map = new TreeMap<String, Server>() ;https://stackoverflow.com/questions/17015575
复制相似问题