Contoh Penggunaan Perulangan While dalam Java

Perulangan bentuk While memiliki syntax sebagai berikut
while(<boolean condition>){
 
        <Block of statements>;

}
Contoh penggunaannya adalah sebagai berikut :



public class SimpleWhileLoopExample {
   public static void main(String[] args) {
      int i = 0;
      while(i <= 5) {
         System.out.println("i is : " + i);
         i++;
     }
   }
}
Selamat mencoba, semoga membantu.

1 comments - Add Yours

UX Designers Delhi mengatakan...

I am extremely impressed along with your writing abilities, Thanks for this great share.

Posting Komentar