Saturday, January 2, 2010

For, While, and Do...While

Want to know distinctive repetitive utilizes for, while, or do … while? This following cheque ^^
Repetitive third this results same output, as screen shoot here under:


Example programs to utilize while
public class perulangan {
   public static void main (String [] args) {
      int i=0;
      while(i<9) {
           System.out.println(“Baris-“ +i);
           i++;
      }
   }
}

Example programs to utilize do...while
public class perulangan1 {
   public static void main (String [] args) {
      int i=0;
      do {
         System.out.println(“Baris-“+i);
         i++;
      }
      while(i<9);
   }

Example programs to utilize for
public class perulangan2 {
   public static void main (String [] args) {
      for(int i=0; i<9; i++) {
         System.out.println(“Baris-“+i);
      }
   }
}

Download this material in here

No comments:

Post a Comment