A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 黑马-王鹏 中级黑马   /  2013-4-7 10:37  /  1316 人查看  /  4 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

本帖最后由 黑马-王鹏 于 2013-4-7 10:47 编辑
  1. //装饰类
  2. class Student
  3. {
  4.         public void study()
  5.         {
  6.      System.out.println("语文、数学");
  7.         }
  8. }
  9. class SuperStudent
  10. {
  11.         private Student s;
  12.         SuperStudent(Student s)
  13.         {
  14.                 this.s = s;
  15.         }
  16.         public void superStudy()
  17.         {
  18.      System.out.println("外语");
  19.          s.study();
  20.          System.out.println("电脑");
  21.          System.out.println("驾校");
  22.         }
  23. }
  24. class  SuperStudentDemo
  25. {
  26.         public static void main(String[] args)
  27.         {
  28.                 Student s = new Student();
  29.                 SuperStudent ss = new SuperStudent(s);
  30.                 ss.superStudy();
  31.         }
  32. }
复制代码
C:\Documents and Settings\wangpeng\桌面
为什么编译通过了,运行时出现错误啊?

}2902SASB$$KJ[$53%7SB[A.jpg (36.58 KB, 下载次数: 4)

}2902SASB$$KJ[$53%7SB[A.jpg

4 个回复

倒序浏览
看看你的文件名是不是SuperStudentDemo,你的代码在我这可以运行

回复 使用道具 举报
wanggang 发表于 2013-4-7 10:42
看看你的文件名是不是SuperStudentDemo,你的代码在我这可以运行

谢谢哈,又犯低级错误了
回复 使用道具 举报
你用的editplus吧,我以前也经常犯这个错误
以后记住这个异常就可以了
1.要细心 2.要细心 3.要更加细心
回复 使用道具 举报
我手心里的宝 发表于 2013-4-7 10:49
你用的editplus吧,我以前也经常犯这个错误
以后记住这个异常就可以了
1.要细心 2.要细心 3.要更加细心 ...

嗯,我都犯好几次这种错误了,看代码看了半天都不知道错在哪里,以后一定要记住这个异常了
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马