1. 程式人生 > >while死迴圈

while死迴圈

1、沒有自增自減變數

public static void main(String[] args){
		int x = 0;
	      while( x < 3 ) {
	         System.out.println("value of x : " + x );
	         //i++;
	         continue; 
	      }   
	  }

2、條件永遠為true

public static void main(String[] args){
		int x = 0;
	     while(true) {
	         System.out.println("value of x : " + x );    
	      }   
	  }
	

3、do while中沒有自增自減變數

public static void main(String[] args){
		  int x = 0;
	      do{
	         System.out.println("value of x : " + x );
	      }while( x < 3 );
	}

4、死程式碼

public static void main(String[] args){
		while(true){}
	}