What i am suppose to do is create a method that is able to copy a 2d array. The code below is what I have so far, the first part is made for user to enter the array info and the bottom is were my problem starts. I don't know what is wrong, every time I run the code I get something like this :
Enter the no. of rows: 2
Enter the no. of columns: 2
Enter the elements: 3
Enter the elements: 7
Enter the elements: 5
Enter the elements: 8
[[I@3669ae9f
[[I@3669ae9f
This is my code:
public static int[][] copyArray(int[][] array) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the no. of rows: ");
int m = Integer.parseInt(br.readLine());
System.out.println("Enter the no. of columns: ");
int n = Integer.parseInt(br.readLine());
int A[][] = new int[m][n];
for(int row = 0; row < m; row++)
{
for(int column = 0; column < n; column++)
{
System.out.print("Enter the elements: ");
A[row][column] = Integer.parseInt(br.readLine());
}
}
int[][] newArray = new int[A.length][];
for(int x = 0; x < A.length; x++)
{
newArray[x] = A[x].clone();
System.out.println(newArray);
}
return newArray;
}