I have a 2D array of 5 rows and 5 columns, all filled with the value 0. How can I make my program do this:
Enter any random combination of row and column like 2-5, without the [] brackets. Just typing 2-5 should be enough to make my program understand I mean row 2 column 5
Assign value I enter to said array in row-column combination.
This is what I got so far. As you can see I have only managed to output the values of all array elements.
import java.util.*;
public class stink {
public static void main(String[]args){
int[][] kuk = new int[5][5];
printMatrix(kuk);
}
public static void printMatrix(int[][] matrix)
{
for (int row = 0; row < matrix.length; row++)
{
for (int col = 0; col < matrix[row].length; col++)
System.out.printf("%2d", matrix[row][col]);
System.out.println();
}
}
}