I have no idea what is wrong with my code, it will not compile because the compiler can not find variable k.
my code:
public class t
{
public static void main(String args[])
{
int r = 10;
int c = 10;
char[][] map = new char[r][c];
for(int i = 1; i < (r - 1); i++)
{
for(int k = 1; k < (c - 1); k++);
{
map[i][k] = '$';
}
}
}
}
error it’s giving me:
symbol: variable k
location: class t
1 error
I keep thinking it is a scope issue, but variable k is inside of the nested for-loop, so it should be fine right?
You have a semicolon a the end of your “k” for loop; remove it. Change
to