java Collections工具类辅助方法非Collection接口

提供了对Set、List和Map排序、填充和查找元素等辅助方法

Collections.shuffle() 随机排列容器内元素
Collections.reverse() 逆序排列
Collections.sort() 递增排序
Collections.binarySearch() 查找元素,并返回元素的索引

  List<String> list =new ArrayList<>();
    Collections.reverse(list);
    Collections.sort(list);
    int f=Collections.binarySearch(list,"a2");

猜你喜欢

转载自blog.51cto.com/14437184/2422161
今日推荐