I hava a problem to clone a two-dimensional array of float entries to another two-dimensional array of similar type and size. Below is my coding, anyone can help me to check which part I got wrong? Thanks.
public class Clone2Darray {
public static int[][] clone(int[][] a) throws Exception {
float b[][] = new int[a.length][a[0].length];
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[0].length; j++)
b[i][j] = a[i][j];
}
return b;
}
public static void main(String args[]) {
float a[][]= {{1.513,2.321,3.421},{4.213,5.432,6.123},{7.214,8.213,9.213}};
try {
float b[][] = Clone2Darray.clone(a);
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[0].length; j++) {
System.out.print(b[i][j] + " ");
}
System.out.println();
}
} catch (Exception e) {
System.out.println("Error!!!");
}
}
}
My coding come out these errors like below:
C:\Users\User-Win7\.netbeans\7.1\var\cache\executor-snippets\run.xml:48:
Cancelled by user.
BUILD FAILED (total time: 4 seconds)
I want the output like below:
1.513 2.321 3.421
4.213 5.432 6.123
7.214 8.213 9.213
1.513 2.321 3.421
4.213 5.432 6.123
7.214 8.213 9.213