Getting the array length of a 2D array in Java

前端 未结 12 2327
耶瑟儿~
耶瑟儿~ 2020-11-27 09:27

I need to get the length of a 2D array for both the row and column. I’ve successfully done this, using the following code:

public class MyClass {

 public s         


        
12条回答
  •  鱼传尺愫
    2020-11-27 10:01

    Try this following program for 2d array in java:

    public class ArrayTwo2 {
        public static void main(String[] args) throws  IOException,NumberFormatException{
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            int[][] a;
            int sum=0;
            a=new int[3][2];
            System.out.println("Enter array with 5 elements");
            for(int i=0;i

提交回复
热议问题