1.Student
1 public class Student { 2 public void study(){ 3 System.out.println("学生学习---"); 4 } 5 }
2.Worker
1 public class Worker { 2 public void work(){ 3 System.out.println("工人工作----"); 4 } 5 6 }
3.GraduateStudent
1 /** 2 * 在职研究生类(既可以学习 +又能工作) 3 * @author ganchuanpu 4 * 5 */ 6 public class GraduateStudent extends Student{ 7 8 class Innner extends Worker{ 9 10 } 11 12 }
4.Test
public class TestInner { public static void main(String[] args) { GraduateStudent graduateStudent=new GraduateStudent(); graduateStudent.study(); System.out.println("---------------------"); graduateStudent.new Innner().work(); } }
学生学习--- --------------------- 工人工作----