Question: In java I am trying to find the second smallest and second largest number in a 2d array. int array[][] = {{1,2.3},{3,4,5,},{6,7,8}}; int n =
In java I am trying to find the second smallest and second largest number in a 2d array.
int array[][] = {{1,2.3},{3,4,5,},{6,7,8}};
int n = array.length;
for (int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
if(array[i] < [j]) }
int temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
}
System.out.print(array[1]);
system.out.print(array[n-2]);
However I get an error and I am not sure how to fix it.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
