java.util.Arrays 总结
java.util.Arrays提供了很多对数组进行操作的使用方法,熟悉一下比较好。总结如下:
1.binarySearch,二分搜索,在数组中查找指定的值。
2.复制相关的: copyOf,copyOfRange
3.相等判断相关的方法 : equals ,hashCode,toString
深度相等(api文档中有具体的定义): deepEquals,deepHashCode和deepToString,可用于多维数组的判断。
4.排序:sort方法
5.填充:fill方法
6.asList方法: 这个很常用,文档的说明如下:
Arrays (Java 2 Platform SE 6)<link href="../../stylesheet.css" title="Style" rel="stylesheet" type="text/css"><script type="text/javascript">function windowTitle(){ if (location.href.indexOf('is-external=true') == -1) { parent.document.title="Arrays (Java 2 Platform SE 6)"; }}</script><noscript></noscript>public static <T> List<T> asList(T... a)返回一个受指定数组支持的固定大小的列表。(对返回列表的更改会“直接写”到数组。)此方法同 Collection.toArray() 一起,充当了基于数组的 API 与基于 collection 的 API 之间的桥梁。返回的列表是可序列化的,并且实现了 RandomAccess。 此方法还提供了一个创建固定长度的列表的便捷方法,该列表被初始化为包含多个元素:
List<String> stooges = Arrays.asList("Larry", "Moe", "Curly");
页:
[1]