I'm am very new to programming and working just in the CLI. I may be trying to do something completely wrong or going about it the wrong way. I am using a nested for loop to create a 2d grid array, assigning characters to my (int i) and (int k) to create a border. now in another method am trying to inject a value to the grid so when the grid is printed I can change the char in that position of the grid. I have done this manually building the gird as you can just select grid[1][2] = a. just can't seem to wrap my head around it using the for a loop. reason for using the for a loop as I can adjust the size of the grid and display the border by just adjusting grid size.
public void printMap() {
map = new int[15][30];
System.out.println();
for (int i = 0; i < map.length; i++){
System.out.print("|");
for (int k = 0; k < map[i].length; k++){
if (i == 0) {
System.out.print("-");
}else if (i == map.length-1){
System.out.print("_");
}else if (k == -5){ // i want to inject -5 from another method into the grid so it prints out '^' where ever i inject -5
System.out.print("^");
}else {
System.out.print(" ");
}
}
System.out.println("|");
}
}