1. 程式人生 > 實用技巧 >IO流新版jdk自動關閉

IO流新版jdk自動關閉

package com.vfsd.core;

public class Test1 {
    public static int[] a1= {3,8,2,5,1,9};
    public static void main(String[] args) {
        
        
        print1();
        
        for(int k=0;k<a1.length-1;k++)
        {
            for(int k2=k+1;k2<a1.length;k2++)
            {
                
int index1=a1[k]; int index2=a1[k2]; if(index1>index2) { a1[k]=index2; a1[k2]=index1; //continue; //break; } print1(); }
//print1(); } print1(); } public static void print1(){ System.out.println("==================================== "); System.out.print(" ["); for(int k=0;k<a1.length;k++) { System.out.print(a1[k]+" "); } System.out.print(
"]\n"); System.out.println("==================================== "); } }

==================================== 
 [3 8 2 5 1 9 ]
==================================== 
==================================== 
 [3 8 2 5 1 9 ]
==================================== 
==================================== 
 [2 8 3 5 1 9 ]
==================================== 
==================================== 
 [2 8 3 5 1 9 ]
==================================== 
==================================== 
 [1 8 3 5 2 9 ]
==================================== 
==================================== 
 [1 8 3 5 2 9 ]
==================================== 
==================================== 
 [1 3 8 5 2 9 ]
==================================== 
==================================== 
 [1 3 8 5 2 9 ]
==================================== 
==================================== 
 [1 2 8 5 3 9 ]
==================================== 
==================================== 
 [1 2 8 5 3 9 ]
==================================== 
==================================== 
 [1 2 5 8 3 9 ]
==================================== 
==================================== 
 [1 2 3 8 5 9 ]
==================================== 
==================================== 
 [1 2 3 8 5 9 ]
==================================== 
==================================== 
 [1 2 3 5 8 9 ]
==================================== 
==================================== 
 [1 2 3 5 8 9 ]
==================================== 
==================================== 
 [1 2 3 5 8 9 ]
==================================== 
==================================== 
 [1 2 3 5 8 9 ]
====================================