Skip to content

Instantly share code, notes, and snippets.

@mrnirva
Created September 4, 2020 12:08
Show Gist options
  • Save mrnirva/f43c1a2cbcc29b1935548c139f0796d0 to your computer and use it in GitHub Desktop.
Save mrnirva/f43c1a2cbcc29b1935548c139f0796d0 to your computer and use it in GitHub Desktop.
package donguler;
public class Donguler {
public static void main(String[] args) {
// For-each -> For döngüsünün array tipler için kısaltılmış halidir.
int[] sayilar = {5,10,15,20,25};
// For ile dizi yazdurma
for(int i=0; i<sayilar.length; i++){
System.out.println(sayilar[i]);
}
System.out.println("*************************");
// For-each ile dizi yazdırma
/*
for'dan sonra dizinin tipi yazılıp bir değişken ismi yazılır
: işaretinden sonra dizinin adı yazılır
Bileşen her defasıda değişkene atanır
Bunu kullanarak işlemler gerçekleştirebiliriz
*/
for(int sayi : sayilar){
System.out.println(sayi);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment