我写了一段,但只能对key进行排序
String[] arraySources = {"1","2","3","0"};
int[] arrayValue = {1,424,32,123};
Map mapCurrentWebSite = new TreeMap( new Comparator(){
public int compare(Object o1, Object o2) {
int map1 = Integer.parseInt(((String)o1));
int map2 = Integer.parseInt(((String)o2));
return map1-map2;
}
});
for(int i=0;i<arraySources.length;i++){
mapCurrentWebSite.put(arraySources[i],new Integer(arrayValue[i]));
}
Collection col = mapCurrentWebSite.values();
Vector v1 = new Vector(col);
for(int i=0;i<v1.size();i++){
System.out.println((Integer)v1.get(i));
}
String[] arraySources = {"1","2","3","0"};
int[] arrayValue = {1,424,32,123};
Map mapCurrentWebSite = new TreeMap( new Comparator(){
public int compare(Object o1, Object o2) {
int map1 = Integer.parseInt(((String)o1));
int map2 = Integer.parseInt(((String)o2));
return map1-map2;
}
});
for(int i=0;i<arraySources.length;i++){
mapCurrentWebSite.put(arraySources[i],new Integer(arrayValue[i]));
}
Collection col = mapCurrentWebSite.values();
Vector v1 = new Vector(col);
for(int i=0;i<v1.size();i++){
System.out.println((Integer)v1.get(i));
}
解决方案 »
- 绘制抛物线问题。 就是根据抛物线方程获得N个点,然后连接前一个和后一个点,然后作成抛物线,问题是怎么让连接的线很平滑?坐等高人指教。
- 学了JAVA SE 基础,想做几个项目巩固一下,大家有没有好的项目,拖一个上来!
- Deprecated members 是什么东西??非常不解
- 新人Runtime类的问题请教
- socket连接UNIX服务器的问题
- SQL
- 关于 JTree 树展开状态保存的问题(在线等待,十分紧急)
- 一个JAVA做的小程序
- 怎样在Java HTTPServer 中定义一个全局变量
- webspere studio application developer 的编辑器中不能输入中文!?
- 我的第一条java程序就不行!搞了半日还是不行.高人指请点下!程序没有出错,但结果没有达到我所想的!
- sina这些网站是不是不让爬虫爬啊?
TreeMap就是要对key进行排序啊
构造一个新的空映射,该映射根据给定的比较器进行排序.比较的 都是key的值,红黑树都这样的。 要想比较value的值,另想办法