[Java 11] ArraysDemo 数组简单的排序,填充操作

Arrays
public class ArraysDemo {
    public static void main(String[] args) {
        int temp[] = {3, 5, 7, 9, 1, 2, 6, 8};
        Arrays.sort(temp);
        System.out.println("排序后的数组 : ");
        System.out.println(Arrays.toString(temp));
        int point = Arrays.binarySearch(temp, 3);
        System.out.println(point);
        Arrays.fill(temp, 3);
        System.out.println("数组填充 : ");
        System.out.println(Arrays.toString(temp));
    }
}

Output

排序后的数组 : 
[1, 2, 3, 5, 6, 7, 8, 9]
2
数组填充 : 
[3, 3, 3, 3, 3, 3, 3, 3]

posted @ 2014-06-05 10:10  小尼人00  阅读(183)  评论(0编辑  收藏  举报