Java集合工具类Collections

初学Java看到Collections.shuffle(),我说Collection源码里没有这个静态方法啊
细看才发现,工具类Collections多了一个s

1 Collections简介

package java.util包里

  • java8 文档原文
    This class consists exclusively of static methods that operate on or return collections. It contains polymorphic algorithms that operate on collections, “wrappers”, which return a new collection backed by a specified collection, and a few other odds and ends.
  • 译文:
    此类仅由对集合进行操作返回集合的静态方法组成。它包含对集合进行操作的多态算法,“包装器”(wrappers)返回由指定集合支持的新集合,以及其他一些零碎的东西。

2 常用方法

方法说明
void shuffle(List<?> list)使用默认随机性对指定的列表元素进行随机重新排序
void shuffle(List<?> list, Random random)通过使用指定的随机性对列表元素进行随机重新排序来工作
void sort(List list)默认排序
void sort(List list, Comparator<? super T> c)根据比较器升序排列
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值