0
package mainPackage;

import java.util.Random;

public class Test {
    public static void main(String args[]){
        int[][] d = new int[][]{{34,43,23,54,24},{43,34,32,43,}};
        int g = d.length;
        int k = d[1].length;
        for(int i = 0; i<d.length;i++){
            System.out.println(d[i]);
        }
        for(int j = 0; j<d.length;j++){
            System.out.println(d[j]);
        }
    }
}

instead of printing out the arrays it print this out

[I@15db9742

[I@6d06d69c

[I@15db9742

[I@6d06d69c

How can I fix it. and what is the problem? Do I need to convert something?

Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724

1 Answers1

1

You need to use Arrays.toString(yourArray) to get a meaningful representation of your array. The default toString implementation for arrays gives the output you are seeing.

In your case, write

System.out.println(Arrays.toString(d[i]));
Kon
  • 10,702
  • 6
  • 41
  • 58