package com.company; public class ArrayMinMaxEachString { public static void main(String[] args) { int[][] array = { {1, 2, 3, 4, 5, 6, 7, 8, 9}, {11, 12, 13, 14, 15, 16, 17, 18, 19} }; for (int i = 0; i < array.length; i++) { for (int j = 0; j < array[0].length; j++) { System.out.print(array[i][j] + " "); } System.out.println(); } //min int min = array[0][1]; for (int k = 0; k < array.length; k++) { if (min > k) { min = k; } } System.out.println("\n\nMin is: " + min); } }
Can you please explain what exactly am I doing wrong? Why doesn't it show the minimum number?
--- Update ---
My assignment looks like this, in case it helps anyone:
Create a two-dimensional 5x8 array of type int and initialize it with an initialization block.
Find the maximum and minimum value in each "line" and write these values into a 5x2 two-dimensional array.
Print both arrays.