本帖最后由 钱兆元 于 2012-1-31 21:07 编辑
自己瞎写的代码,各位帮忙看看哪里错了,多谢- class Try{
- int x=9;
- }
- class Test{
- Try t;
- public void show(){
- System.out.println(t.x);
- }
- }
- class Demo
- {
- public static void main(String[] args)
- {
- Try t=new Try();
- Test e=new Test();
- e.show();
- }
- }
复制代码 错误异常:
Exception in thread "main" java.lang.NullPointerException
at demo.Test.test(Demo.java:9)
at demo.Demo.main(Demo.java:18)
|