1,一维数组的遍历

int[] a = newint[5];

       for(inti=0;i<a.length;i++)

       {

           System.out.print(a[i]+"   ");

       }

for(intt : a)

       {

           System.out.print(t+"  ");

}


2,二维数组的遍历

int[][] a2 = newint[3][4];

       for(inti=0;i<a2.length;i++)

       {

           for(intj=0;j<a2[i].length;j++)

           {

              a2[i][j] = i+j;

System.out.print(p+"   ");

           }

System.out.println();

       }

for(int[] t : a)

       {

           for(intp : t)

           {

                a2[i][j] = i+j;

              System.out.print(p+"    ");

           }

           System.out.println();

       }

3,冒泡排序

         int data [] = new int [] {1,3,2,6,10,0,5,8} ;

                   for (int x = 0 ; x < data.length ; x ++) {

                            for (int y = 0 ; y < data.length - 1 ;y ++) {

                                     if (data[y] > data[y + 1]) {     // 后面的小

                                               int t =data[y] ;     // 第三方接收

                                               data[y]= data[y + 1] ;

                                               data[y + 1] = t ;

                                     }

                            }

                   }