java while 与for 区别

class TestCompartor  {
    
    public static void main(String[] args) {
        int j = 1;
        while(j <5){
            System.out.println("j ="+j);
            j++;
        }
        System.out.println("j =========="+j);
        
        for(int i = 1;i <5 ;i++)
        {
            System.out.println("i ="+i);
        }
        //System.out.println("i ==========="+i);
    
    }   
}

运行结果如下:

2222.bmp

标签: none