do-while() örnekleri

                        booleanflag;

                        flag=true;

                        intsayi;

                        sayi=1;

                        do {

                                    if(sayi==5) {

                                               break;

                                    }

                                    if(sayi==1) {

                                               flag=false;

                                    }

                                    System.out.println("merhaba");

                                    sayi++;

                                   

                        }while(flag==false);

 

 

                 intsayi;

                 sayi=-5;

                

                 do {

                         if(sayi==6) {

                                     break;

                         }

              

                         System.out.println(sayi);

                         sayi--;

                 }while(sayi>0);

                

                 System.out.println(sayi);

Yorum ekle