how to get matrix row and column

 

package algorithm.codingpractice;

public class Matrixlength
{

    /**
     * @param args
     */
    public static void main( String[] args )
    {
        // TODO Auto-generated method stub
        int[][] matrix = new int[3][4];
        System.out.println( matrix.length );
        System.out.println( matrix[0].length );
        int[][][] matrix1 = new int[3][4][5];
        System.out.println( matrix1.length );
        System.out.println( matrix1[0].length );
        System.out.println( matrix1[0][0].length );

    }

}

result :

 

3
4
3
4
5

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s