Topic: 大家好我太笨了('else' without 'if')

  Print this page

1.大家好我太笨了('else' without 'if') Copy to clipboard
Posted by: czg4444
Posted on: 2006-09-02 13:40


class IF
{
public static void main(String args[])
{
int x,y;
x=10;
y=20;
if(x!=y);{
if(x>y);
System .out.println("x的值比y的值大。");
else
System .out.println("x的值比y的值大。");
}
else
System.out.println("x的值与y的值相等。");
}}

我太本了
IF.java [11:1] 'else' without 'if'
else
^
IF.java [14:1] 'else' without 'if'
else
^
2 errors
编译 IF. 时出错
请帮帮我
谢谢大家

2.Re:大家好我太笨了 [Re: czg4444] Copy to clipboard
Posted by: nothing
Posted on: 2006-09-02 14:51




public class IF{
  public static void main(String args[]){
    int x,y;
    x=10;
    y=20;
    
    if(x!=y){
        if (x>y)
          System .out.println("x的值比y的值大。");
        else
          System .out.println("x的值比y的值小。");
    }else
    System.out.println("x的值与y的值相等。");
  }
}




3.Re:大家好我太笨了 [Re: czg4444] Copy to clipboard
Posted by: Novo
Posted on: 2006-09-02 16:31

把if()后面的分号去掉就好了.看书时仔细点.

4.Re:大家好我太笨了('else' without 'if') [Re: czg4444] Copy to clipboard
Posted by: lijiye
Posted on: 2006-09-04 11:47

关键是对JAVA代码的书写格式不是很熟悉呀!

5.Re:大家好我太笨了('else' without 'if') [Re: czg4444] Copy to clipboard
Posted by: haiming
Posted on: 2006-09-04 17:09

找个好的编程工具可以减少这种错误

6.Re:大家好我太笨了('else' without 'if') [Re: czg4444] Copy to clipboard
Posted by: lwfllr
Posted on: 2006-09-04 21:36

if(x!=y);{ if(x>y);
这里的分号~~


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923