|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
public static void sort(int[] a)
public static void sort(int[] a,int fromIndex, int toIndex)
public static void sort(long[] a)
public static void sort(long[] a,int fromIndex, int toIndex)
public static void sort(short[] a)
public static void sort(short[] a,int fromIndex, int toIndex)
public static void sort(char[] a)
public static void sort(char[] a,int fromIndex, int toIndex)
public static void sort(byte[] a)
public static void sort(byte[] a,int fromIndex, int toIndex)
public static void sort(double[] a)
public static void sort(double[] a,int fromIndex, int toIndex)
public static void sort(float[] a)
public static void sort(float[] a,int fromIndex, int toIndex)
|
对指定组的指定范围按数字升序进行排序。排序的范围从索引 fromIndex(包括)一直到索引 toIndex(不包括)。(如果 fromIndex==toIndex,则排序范围为空。)
a – 要排序的数组
fromIndex – 要排序的第一个元素的索引(包括)
toIndex – 要排序的最后一个元素的索引(不包括)
|
1
2
|
public static void sort(Object[] a)
public static void sort(Object[] a,int fromIndex, int toIndex)
|
同上,不过数组中的所有元素都必须实现 Comparable 接口。此外,数组中的所有元素都必须是可相互比较的(也就是说,对于数组中的任何 e1 和 e2 元素而言,e1.compareTo(e2) 不得抛出 ClassCastException)。
保证此排序是稳定的:不会因调用 sort 方法而对相等的元素进行重新排序。
|
1
2
|
public static <T> void sort(T[] a, Comparator<? super T> c)
public static <T> void sort(T[] a,int fromIndex,int toIndex,Comparator<? super T> c)
|
根据指定比较器产生的顺序对指定对象数组进行排序。数组中的所有元素都必须是通过指定比较器可相互比较的(也就是说,对于数组中的任何 e1 和 e2 元素而言,c.compare(e1, e2) 不得抛出 ClassCastException)。
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
public static int binarySearch(long[] a,long key)
public static int binarySearch(long[] a,int fromIndex,int toIndex,long key)
public static int binarySearch(int[] a,int key)
public static int binarySearch(int[] a,int fromIndex,int toIndex,int key)
public static int binarySearch(short[] a,short key)
public static int binarySearch(short[] a,int fromIndex,int toIndex,short key)
public static int binarySearch(char[] a,char key)
public static int binarySearch(char[] a,int fromIndex,int toIndex,char key)
public static int binarySearch(byte[] a,byte key)
public static int binarySearch(byte[] a,int fromIndex,int toIndex,byte key)
public static int binarySearch(double[] a,double key)
public static int binarySearch(double[] a,int fromIndex,int toIndex,double key)
public static int binarySearch(float[] a,float key)
public static int binarySearch(float[] a,int fromIndex,int toIndex,float key)
public static int binarySearch(Object[] a,Object key)
public static int binarySearch(Object[] a,int fromIndex,int toIndex,Object key)
public static <T> int binarySearch(T[] a,T key,Comparator<? super T> c)
public static <T> int binarySearch(T[] a,int fromIndex,int toIndex,T key,Comparator<? super T> c)
|
使用二分搜索法来搜索指定数组的范围,以获得指定对象。在进行此调用之前,必须根据指定的比较器对范围进行升序排序。如果没有对范围进行排序,则结果是不确定的。如果范围包含多个等于指定对象的元素,则无法保证找到的是哪一个。
以上就是java Arrays工具类的实例详解,关于java的文章本站还有很多,大家可以搜索参考,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
原文链接:http://yaliya.iteye.com/blog/2384942
相关文章
- ASP.NET自助建站系统的域名绑定与解析教程 2025-06-10
- 个人服务器网站搭建:如何选择合适的服务器提供商? 2025-06-10
- ASP.NET自助建站系统中如何实现多语言支持? 2025-06-10
- 64M VPS建站:如何选择最适合的网站建设平台? 2025-06-10
- ASP.NET本地开发时常见的配置错误及解决方法? 2025-06-10
- 2025-07-10 怎样使用阿里云的安全工具进行服务器漏洞扫描和修复?
- 2025-07-10 怎样使用命令行工具优化Linux云服务器的Ping性能?
- 2025-07-10 怎样使用Xshell连接华为云服务器,实现高效远程管理?
- 2025-07-10 怎样利用云服务器D盘搭建稳定、高效的网站托管环境?
- 2025-07-10 怎样使用阿里云的安全组功能来增强服务器防火墙的安全性?
快网idc优惠网
QQ交流群
-
2025-05-27 61
-
2025-05-25 47
-
日本网站建设成本:预算有限的情况下如何选择性价比高的服务商?
2025-06-04 101 -
2025-05-29 70
-
2025-05-29 95

