Contoh Program Java Array 1 Dimensi
class Array_1
{
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]);
String [] y = new String [3]; //cara 2
y[0]="Joko Budi Bagus";
y[1]="Budi";
y[2]="Iwan";
System.out.println(" Nilai y[0]:" + y[0]);
System.out.println(" \nNilai y[1]:" + y[1]);
System.out.println(" \nNilai y[2]:" + y[2]);
}}
{
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]);
String [] y = new String [3]; //cara 2
y[0]="Joko Budi Bagus";
y[1]="Budi";
y[2]="Iwan";
System.out.println(" Nilai y[0]:" + y[0]);
System.out.println(" \nNilai y[1]:" + y[1]);
System.out.println(" \nNilai y[2]:" + y[2]);
}}
Ditulis Oleh : Unknown ~ Gubuk Curhat
Artikel Contoh Program Java Array 1 Dimensi ini diposting oleh Unknown pada hari Senin, 04 November 2013. Terimakasih atas kunjungan Anda serta kesediaan Anda membaca artikel ini. Kritik dan saran dapat anda sampaikan melalui kotak komentar.
0 komentar:
Posting Komentar