Java,谁能帮我看看这个程序错在哪里,谢谢

来源:百度知道 编辑:UC知道 时间:2024/07/08 20:01:44
public class test9
{
public static void main(String[] x)
{
int x=1;
while(x<6);
{
I++;
if(x<=6);
System.out.println("hello");
}
}
}
希望能解释为什么,谢谢

while(x<6)后不该有分号,分号代表语句的结束 去掉分号
另外把 String【】 x的x改掉 以便区分 最好args符合规范 听来类名第一个字母要大写 基本规范
if(){}语句也要注意 你可以这样写:
public class Test9
{
public static void main(String[] args) {
int x=1;
while(x<6)
{
x++;
if(x<=6)
{
System.out.println("hello");
}
}
}
}

public static void main(String[] x)

改为

public static void main(String[] args)

String[] x
int x 啥意思? 变量重复了

I++ 这个 I 从哪里来的啊??

都是些格式上错误,应该是初学者吧!
我改了下,看看,你要的是这种结果吗?
public class Test9 {
public static void main(String[] args) {
int x=1;
while(x<6){
x++;
if(x<=6);
System.out.println("hello");
}
}
}

x改成args, 之后 L 没有声明变量类型~

String[] x 和 int x=1; 变量重复
l++; 未声明变量