public class sanjiaoxing {
public static void main(String[] args) {
int line = 5 ;
for (int x=0;x<5;x++);{
for (int y=0;y<5-x;y++);{
System.out.print(" ");
}
for (int y=0;y<=x;y++);{
System.out.print("* ");
}
System.out.println();
}
}
}
为什么会提示:x cannot be resolved to a variable
求解!
------解决方案--------------------
public class sanjiaoxing {
public static void main(String[] args) {
int x=0;
for (x=0;x<5;x++)
{
for (int y=0;y<5-x;y++)
{
System.out.print(" ");
}
for (int y=0;y<=x;y++)
{
System.out.print("* ");
}
System.out.println("");
}
}
}
------解决方案--------------------
for (int x=0;x<5;x++);{
这行不该有分号的,去掉就能运行,不过你程序不对
------解决方案--------------------
仔细看了下,你所有FOR语句后面都多加了个;,去掉对了的,记得给分啊