1. Array Satu Dimensi
Merupakan sebuah
variabel yang menyimpan sekumpulan data yang memiliki tipe sama dan elemen yang
akan diakses hanya melalui 1 indeks atau subskrip.
2. Bentuk umum
pendeklarasian:
nama_array[jumlah_eleman];
Program sederhana :
Contoh Program ArrSatu.java
class SingleArray
{
public static void
main(String[] args)
{
int [] x; // Cara 1
x = new int[3];
x[0]
= 20 ;
x[1]
= 10 ;
x[2]
= 30;
System.out.println("Nilai
x[0] : " + x[0]);
System.out.println("Nilai
x[1] : " + x[1]);
System.out.println("Nilai
x[2] : " + x[2]);
int
[] y = new int[3];
y[0]
= 20 ;
y[1]
= 10 ;
y[2]
= 30;
System.out.println("Nilai
y[0] : " + y[0]);
System.out.println("Nilai
y[1] : " + y[1]);
System.out.println("Nilai
y[2] : " + y[2]);
int[]
z = {20,10,30};
System.out.println("Nilai
z[0] : " + z[0]);
System.out.println("Nilai
z[1] : " + z[1]);
System.out.println("Nilai
z[2] : " + z[2]);
}
}
1 komentar:
Buffalo Billiards ford fusion titanium - TiG - Titanium Arts
Buffalo Billiards ford fusion titanium. used ford edge titanium A little, a little, seiko titanium and an important element. titanium quartz Our original recipe uses titanium density only cheddar, but guy tang titanium toner our sauce is made with a touch of
Posting Komentar