I'm currently studying and came across a question which asks to find the minimum value within each row of a 2-dimensional array..and then put all of the minimum values within an array. I already wrote some code but the method produces a really strange output at the console rather than the correct result.
I tested it on this 2d array int[][]array={{3,1,8}, {10,12,2}, {5,7,4}}; , and the output I should have gotten is [1,2,4] but instead i get [I@7852e922
Can someone please tell me what I am doing wrong?
Here is the code..
public static int [] min_row(int[][] n){
int [] result = new int[n.length];
int min=0;
for(int i=0;i<n.length;i++){
for(int j=0;j<n[0].length;j++){
if(n[i][j]<n[i][min]){
min=j;
}
result[i]=n[i][min];
}
}
return result;
}