Multidimensional Arrays lengths in Java

后端 未结 8 1110
一个人的身影
一个人的身影 2020-12-04 18:15

How to find the lengths of a multidimensional array with non equal indices?

For example, I have int[][] pathList = new int[6][4]

Without actuall

8条回答
  •  难免孤独
    2020-12-04 18:59

    In java we can define array of arrays which we call multi dimensional arrays.By array of arrays we mean that a single elment of our array is again an array (in java can be of multiple length).To find length of multi array having all subarray of same size,we can use:

    int[][]a=new int[3][3];//let a[][] be my array
    a.length will work.   //a is an object of proxy class and length is its property.
    

    However,if you have subarrays of different sizes then you have to iterate it.

    for(i=0;i

提交回复
热议问题