Tugas Pemograman 2 ( Array 2 Dimensi) cara 1


/**
* Write a description of class Array2D here.
*
* @author (Hasan Mualim)
* @version (04072010)
*/
public class Array2D
{
public static void main(String[]args){
int[][]arrx;
//cara satu(1) Array 2 Dimensi
arrx=new int[3][3];
arrx[0][0]=1;
arrx[0][1]=2;
arrx[0][2]=3;
arrx[1][0]=4;
arrx[1][1]=5;
arrx[1][2]=6;
arrx[2][0]=7;
arrx[2][1]=8;
arrx[2][2]=9;
System.out.println(“Nilai arrx[0]:”+ arrx[0][0]);
System.out.println(“Nilai arrx[0]:”+ arrx[0][1]);
System.out.println(“Nilai arrx[0]:”+ arrx[0][2]);
System.out.println(“Nilai arrx[1]:”+ arrx[1][0]);
System.out.println(“Nilai arrx[1]:”+ arrx[1][1]);
System.out.println(“Nilai arrx[1]:”+ arrx[1][2]);
System.out.println(“Nilai arrx[2]:”+ arrx[2][0]);
System.out.println(“Nilai arrx[2]:”+ arrx[2][1]);
System.out.println(“Nilai arrx[2]:”+ arrx[2][2]);
}
}

Hasil outputnya:

Nilai arrx[0]:1

Nilai arrx[0]:2

Nilai arrx[0]:3

Nilai arrx[1]:4

Nilai arrx[1]:5

Nilai arrx[1]:6

Nilai arrx[2]:7

Nilai arrx[2]:8

Nilai arrx[2]:9

Tentang hasanmualim

Wong Ndeso
Pos ini dipublikasikan di Tak Berkategori. Tandai permalink.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s