Di bawah ini merupakan coding contoh program array 1 dimensi.
public class Array1D
{
public static void main(String[] args)
{
int um []={17, 15, 12, 10, 19};
String nm []={"Bunga","Rosdiana","Isni","Puji","Indah"};
System.out.println("No Nama Umur");
for(int i=0; i<5; i++)
System.out.println((i+1)+" "+nm[i]+" "+um[i]);
}
}
{
public static void main(String[] args)
{
int um []={17, 15, 12, 10, 19};
String nm []={"Bunga","Rosdiana","Isni","Puji","Indah"};
System.out.println("No Nama Umur");
for(int i=0; i<5; i++)
System.out.println((i+1)+" "+nm[i]+" "+um[i]);
}
}
Outputnya akan tampil seperti gambar dibawah ini.
0 komentar:
Posting Komentar