public class recursion {
public static void main(String[] args)
{
thisclass(0);
}
public static void thisclass(int z)
{
int x = 1;
int y = 3;
if (z==10)
{
System.out.println("Done");
}
else
{
System.out.println(x/y);
x++;
y= y+2;
thisclass(z++);
}
}
}
我现在正在学习递归,当我进入thisclass
方法中的 else 语句时,在打印出异常数量的零后出现错误。
我希望程序做的是运行 10 次并按照 Print 1/3 2/5 3/7 等的方式执行一些操作。
我哪里错了?