Your code compiles and runs for me with one minor fix.
The inner loop in MainClass needs to have it's index (i)
declared. Try for (int i = 0;...
instead of for (i = 0;...