1 package J2SE.Arrays;
2
3 import java.util.*;
4
5 public class ArraysDemo {
6
7 /**
8 * @param args
9 * Arrays中所有方法都为静态方法,此可以不构造一个对象,就能使用该方法
10 */
11 public static void main(String[] args) {
12 // TODO 自动生成方法存根
13 int[] arrs = {3,93,44,55,24,24};
14 for(int i=0; i<arrs.length; i++)
15 {
16 System.out.println("before arrs is "+ arrs[i]);
17 }
18 Arrays.sort(arrs);
19 for(int i=0; i<arrs.length; i++)
20 {
21 System.out.println("after arrs is "+ arrs[i]);
22 }
23 int index = Arrays.binarySearch(arrs,55);
24 System.out.println(index);
25 // System.out.println(Arrays.toString(3));
26 String[] str = new String[5];
27 for(int i=0; i<5; i++)
28 {
29 str[i] = new String(String.valueOf(i));
30 }
31 //asList 为静态方法
32 List<String> listarr = Arrays.asList(str);
33 Iterator<String> it = listarr.iterator();
34 while(it.hasNext())
35 {
36 System.out.println(it.next());
37 }
38
39 }
40
41 }
42