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 27 28 29 30 31 32 33 34
| package com.wang.array;
import org.omg.CORBA.PUBLIC_MEMBER;
import java.util.Arrays;
public class ArrayDemo06 { public static void main(String[] args) { int[] a = {1,2,4,3,999,32626,548,56,89,46}; System.out.println(a); System.out.println(Arrays.toString(a));
Arrays.sort(a); System.out.println(Arrays.toString(a));
Arrays.fill(a,0); System.out.println(Arrays.toString(a)); }
public static void printArray(int[] a){ for (int i = 0; i < a.length; i++) { if (i==0){ System.out.print("["); } if (i==a.length-1){ System.out.print(a[i]+"]"); }else { System.out.print(a[i] + ", "); } } } }
|