Topic: 编译为何出错?

  Print this page

1.编译为何出错? Copy to clipboard
Posted by: 一枝梅
Posted on: 2005-06-15 17:22

public class RTExcept {
  public static void throwit ( ) {
    System.out.print("throwit ");
    throw new RuntimeException( );
  }
  public static void main(String args[]) {
    try {
      System.out.print("hello ");
      throwit( );
    }
    catch (Exception re) {
      System.out.print("caught ");
    }


    finally {
      System.out.print("finally ");
    }
    System.out.print("after ");y=y1;
  }
  int getX() {return x;}
  int getY() {return y;}
}

2.Re:编译为何出错? [Re: 一枝梅] Copy to clipboard
Posted by: lqtchacha
Posted on: 2005-06-15 17:53

可能是
catch(Exception e)

3.Re:编译为何出错? [Re: 一枝梅] Copy to clipboard
Posted by: why
Posted on: 2005-06-15 18:43

System.out.print("after ");
y=y1; // y and y1 not declared and not static
}
int getX() {return x;} // int x not declared
int getY() {return y;} // int y not declared

Why don't you read the error messages from the compiler?

4.Re:编译为何出错? [Re: lqtchacha] Copy to clipboard
Posted by: xiangyu138
Posted on: 2005-06-17 11:44

lqtchacha wrote:
可能是
catch(Exception e)


这个朋友也太不应该的,要加把劲啊
其实,
catch(Exception e)和catch(Exception re)都是一夜的,一面的e只不过是标志符的名称,像public static void main(String args[]);里面的args也可以改为别的名字啊。

楼上的建议很好,为什么你不先运行一下,看看问题出现在什么地方啊?

5.Re:编译为何出错? [Re: 一枝梅] Copy to clipboard
Posted by: lqtchacha
Posted on: 2005-06-18 00:23

哦 我也是才学习的哈!不好意思了!!我会努力的!

6.Re:编译为何出错? [Re: lqtchacha] Copy to clipboard
Posted by: cj1007
Posted on: 2005-06-18 10:28

哪里错了???
代码与提示呢?

7.Re:编译为何出错? [Re: 一枝梅] Copy to clipboard
Posted by: 2352439
Posted on: 2005-06-18 11:17

return x;
return y;
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