Contoh Array
05.10.00ﺑﺴﻢﷲﺍﻠﺮﺤﻤﻦﺍﻠﺮﺤﻴﻢ
public class Array{
public static void main(String[] args) {
String Hari[] = {"Senin", "Selasa", "Rabu", "Kamis", "Jum'at", "Sabtu", "Minggu"};
for(int i = 0; i<Hari.length; i++){
System.out.println(Hari[i]);
}
int angka[]=new int[10];
for(int i=0; i<angka.length; i++){
angka[i]=(int)(Math.random()*10);
}
for(int i=0; i<angka.length; i++){
System.out.println("Data array ke " + i + " adalah " +angka[i]);
}
}
}
0 komentar