当我尝试编译它时,Eclipse 说 i 和 j 尚未初始化。我究竟做错了什么?问题是关于创建一个圆圈。
public class Question2
{
public static void main(String[] args) {
int x = 14;
int y = 8;
int radius = 5;
DrawMeACircle(x,y,radius);
}
public static void DrawMeACircle(int x, int y, int radius)
{
int i, j;
int gridsize = 99;
int loop1;
loop1 = ((x-i)*(x-i))+((y-j)*(y-j));
// The problem is here (in the line above), it say i and j has not been initialized.
int loop2 = loop1-radius*radius;
int c = radius-1;
for (i=0; i<gridsize; i++)
{
//System.out.print("#");
for (j=0; j<gridsize; j++)
{
if(loop2 >=0 && loop2<= c )
{System.out.print("#");}
else
{System.out.print(" ");}
}
System.out.print("\n");
}
}
}