本帖最后由 黑马-王鹏 于 2013-4-7 10:47 编辑
- //装饰类
- class Student
- {
- public void study()
- {
- System.out.println("语文、数学");
- }
- }
- class SuperStudent
- {
- private Student s;
- SuperStudent(Student s)
- {
- this.s = s;
- }
- public void superStudy()
- {
- System.out.println("外语");
- s.study();
- System.out.println("电脑");
- System.out.println("驾校");
- }
- }
- class SuperStudentDemo
- {
- public static void main(String[] args)
- {
- Student s = new Student();
- SuperStudent ss = new SuperStudent(s);
- ss.superStudy();
- }
- }
复制代码 C:\Documents and Settings\wangpeng\桌面
为什么编译通过了,运行时出现错误啊? |
|