import java.util.*;
public class TestMap {
public static void main(String[] args) {
Map map=new TreeMap();
map.put(1,new Elent(1,2));
map.put(2,new Elent(2,0));
map.put(3,new Elent(5,1));
map.put(4,new Elent(7,1));
printKeyValuePairs(map);
}
public static void printValues(Map map){
Collection vs=map.values();
Iterator it=vs.iterator();
while(it.hasNext()){
System.out.println(it.next());
}
}
public static void printKeyValuePairs(Map map){
Set ks=map.keySet();
Iterator it=ks.iterator();
while(it.hasNext()){
Object key=it.next();
Object value=map.get(key);
System.out.println(key+" "+value);
}
}
}
class Elent{
int id,index;
public Elent(int id,int index){
this.id=id;
this.index=index;
}
public int getId(){
return id;
}
public int getIndex(){
return index;
}
}
怎么取KEY值为I的对象ID的值是否为0?