-2

I've tried to figure it out, but couldn't find any reference:

If I get one dimension array's size by: MyArray.length(), how can I get the dimensions of the 2D array, each dimension by itself?

Thank you

1
  • For which "array" ? Commented Nov 7, 2017 at 11:02

2 Answers 2

0

If your 2D array is symmetric and square, you can use:

2Darray.length * 2Darray[0].length
Sign up to request clarification or add additional context in comments.

Comments

0

This method will return number of element in an 2D array:

Code:

static int length(int[][]  array, int NoColumnInArray){
int leng =0;
for(int i = 0 ; i < NoColumnInArray ; i++)
      leng+=array.length();
 return leng;
}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.