Skip to content

Instantly share code, notes, and snippets.

@mrnirva
Last active September 4, 2020 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrnirva/722e21c758562186dbaac57ee0e77db4 to your computer and use it in GitHub Desktop.
Save mrnirva/722e21c758562186dbaac57ee0e77db4 to your computer and use it in GitHub Desktop.
package donguler;
public class Donguler {
public static void main(String[] args) {
// break Örneği
// Sayaç 5 olduğunda döngüyü bitirir
for(int i=0; i<10; i++){
if(i == 5){
break;
}
System.out.println("Sayı: "+i);
}
System.out.println("****************");
int sayi = 0;
while(sayi < 10){
if(sayi == 5){
break;
}
System.out.println("Sayı: "+sayi);
sayi++;
}
System.out.println("****************");
// continue örneği
// Sayaç 5 olduğunda ekrana yazdırmaz bir sonrakine geçer
for(int i=0; i<10; i++){
if(i == 5){
continue;
}
System.out.println("Sayı: "+i);
}
System.out.println("****************");
int sayi2 = 0;
while(sayi2 < 10){
sayi2++;
if(sayi2 == 5){
continue;
}
System.out.println("Sayı: "+sayi2);
}
/*
Çıktı:
Sayı: 0
Sayı: 1
Sayı: 2
Sayı: 3
Sayı: 4
****************
Sayı: 0
Sayı: 1
Sayı: 2
Sayı: 3
Sayı: 4
****************
Sayı: 0
Sayı: 1
Sayı: 2
Sayı: 3
Sayı: 4
Sayı: 6
Sayı: 7
Sayı: 8
Sayı: 9
****************
Sayı: 1
Sayı: 2
Sayı: 3
Sayı: 4
Sayı: 6
Sayı: 7
Sayı: 8
Sayı: 9
Sayı: 10
*/
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment