fork(3) download
  1.  
  2. import java.util.Arrays;
  3.  
  4. public class Main {
  5. public static void main(String[] args) {
  6. int[][] matrix = { { 10, -5, 15 }, { 8, 20, 12 }, { 27, -3, 14 }, { 7, 17, 4 } };
  7. int[] highestNumbers = new int[5];
  8. Arrays.fill(highestNumbers, Integer.MIN_VALUE);
  9. for (int row = 0; row < matrix.length; row++) {
  10. for (int column = 0; column < matrix[row].length; column++) {
  11. int currentEntry = matrix[row][column];
  12. if (currentEntry > highestNumbers[0]) {
  13. highestNumbers[0] = currentEntry;
  14. Arrays.sort(highestNumbers);
  15. }
  16. }
  17. }
  18. System.out.println(Arrays.toString(highestNumbers));
  19. }
  20. }
  21.  
Success #stdin #stdout 0.07s 32604KB
stdin
Standard input is empty
stdout
[14, 15, 17, 20, 27]