package com.hyn;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class DemoCollect {
public static void main(String[] args) {
Map<String, String> map = new HashMap<>();
map.put("d", "d");
map.put("k", "k");
map.put("c", "c");
map.put("a", "a");
map.put("y", "y");
List<String> keys = new ArrayList<String>(map.keySet());
System.out.println(keys.toString());//[d, c, a, k, y]
//集合类排序
Collections.sort(keys);
System.out.println(keys.toString());//[a, c, d, k, y]
}
}
Java集合类排序方式之一
猜你喜欢
转载自blog.csdn.net/u010612373/article/details/52209048
今日推荐
周排行