?? demonarrays.java
字號:
//使用Arrays類中的方法。
import java.util.*;
class DemonArrays
{
public static void main(String[] args)
{
int[] array = {0,1,2,3,4,5,6,7,8,9};
//用20填充數組中7至(9-1)的位置
Arrays.fill(array,7,9,20);
System.out.println("After filling,the array is");
for(int i = 0;i<10;i++) {
System.out.print(array[i] + " ");
}
System.out.println();
//將數組排序
Arrays.sort(array);
System.out.println("After sorting,the array is");
for(int i = 0;i<10;i++) {
System.out.print(array[i] + " ");
}
System.out.println();
//在數組中檢索25
System.out.println("Search 25 in the array : "+ Arrays.binarySearch(array,25));
//在數組中檢索5
System.out.println("Search 5 in the array : "+ Arrays.binarySearch(array,5));
//將數組array同數組arrayB相比較
int[] arrayB = new int[10];
System.out.println("Compare with arrayB : "+Arrays.equals(array,arrayB));
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -