学习 Class Arrays
Docs
Method Summary
- asList
返回固定大小List
1 | List<String> stringList = Arrays.asList("hello", "NTU"); |
- binarySearch
可以在整个数组中查找,也可以在一定范围内查找
支持Long/int/short/double/char/byte/float/object/T类型数组的查找
1 | //以int为例 |
- copy & copyRange
1 | String[] names2 = { "Eric", "John", "Alan", "Liz" }; |
- sort
升序排列
1 | String[] names = { "Liz", "John", "Eric", "Alan" }; |
另外,Arrays的sort方法也可以结合比较器,完成更加复杂的排序。
- toString
返回数组内容的一个String
1 | String[] name = {"hahah", "hahah"}; |
- deepToString
打印多维数组(multidimensional arrays)的内容
- equls
比较两个一维数组是否相等
1 | String[] names1 = { "Eric", "John", "Alan", "Liz" }; |
- deepEquals
判断更复杂的数组是否相等
- fill
向整个数组或一定范围内的数组填充指定内容