WhileEx01.java-후행/선행

CODEDRAGON Development/Java

반응형

while문 - 후행/선행

   

   

소스코드

   

  1. public class WhileEx01 {
  2.    
  3.         public static void main(String[] args) {
  4.                  
  5.                 int i = 10;     //초기식
  6.                  
  7.                 //후행
  8.                 while( i >= 0){ //조건식
  9.                         System.out.println(i--);        //증감식                    
  10.                 }              
  11.                 System.out.println("후행  i : " + i);
  12.                 System.out.println();
  13.                  
  14.                  
  15.                 //선행
  16.                 int j = 10;            
  17.                 while( j >= 0){ //조건식
  18.                         System.out.println(--j);        //증감식                    
  19.                 }              
  20.                 System.out.println("선행  j : " + j);
  21.                 System.out.println();
  22.         }
  23. }


   

출력결과

   

   

반응형