Method di Java

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package nilaiArrayPerBaris;

/**
*
* @author Angga
*/
public class nilaiArrayPerBaris {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int array1[][] = {{1,2,3},{4,5,6}};
int array2[][] = {{1,2},{3},{4,5,6}};
System.out.println(“nilai array1 per baris :”);
cetakArray(array1); //displays array1 by row
System.out.println(“\nnilai array2 per baris :”);
cetakArray(array2); //displays array2 by row
} //end main

public static void cetakArray(int array[][] ){
//loop through array’s rows
for (int row = 0; row < array.length; row++){
//loop through columns of current row
for ( int column = 0; column < array[ row ].length; column++)
System.out.printf(“%2s” , array [ row ][ column ]);
System.out.println(); //start new line of output
}
}

}

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 )

Foto Google

You are commenting using your Google 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 )

Connecting to %s