1.Student 2.Worker 3.GraduateStudent 4.Test ...
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(); } }
學生學習--- --------------------- 工人工作----