Created
September 4, 2020 12:08
-
-
Save mrnirva/f43c1a2cbcc29b1935548c139f0796d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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