java List 排序,升序,降序
import java.util.*;
public class EntrySets {
public static void main(String[] args) {
Map<Object, Object> map = new HashMap<Object, Object>();
map.put("k1", "v1");
map.put("k2", "v2");
getItem(map);
List<Object> kk = new ArrayList<Object>();
kk.add("1");
kk.add("aa");
kk.add("A");
print(sortList(kk));
}
static void getItem(Map map) {
map.forEach((key, value) -> print(key + ":" + value));
}
static void iterByKey(Map map) {
/** iter map by key */
for (Object k : map.keySet()) {
String v = map.get(k).toString();
}
}
static void print(Object o) {
System.out.println(o);
}
static List sortList(List list){
Collections.sort(list);
// 反转
//Collections.reverse(list);
return list ;
}
}
以上是 java List 排序,升序,降序 的全部内容, 来源链接: utcz.com/z/394198.html