public class chocolatecake
{
int rows,cols;
public chocolatecake(int r, int c)
{
rows = r;
cols = c;
}
private String letterBlock[][];
public void fillBlock(String str)
{
boolean hasExtra;
int tracker=0;
for(int y=0;y<rows;y++)
{
for(int x=0;x<cols;x++)
{
letterBlock[y][x] = str.substring(tracker, tracker+1);
System.out.println(letterBlock[y][x]);
tracker++;
}
}
}
}
SO the point of this program is to take a string and put it into an array first in row major order and then in column major order with a different array size, but im stuck here where the compiler is saying nullpointerexception at line 21
letterBlock[y][x] = str.substring(tracker, tracker+1);