内部类既可又继承其它类,也可又实现其它结果,- class Person {
- public void cry() {
- System.out.println("cry!!");
- }
- }
- public class InnerClass {
- public static void main(String[] args ) {
- InnerClass.Student s = new InnerClass().new Student();
- s.cry();
- s.study();
- }
- class Student extends Person {
- public void study(){
- System.out.println("study!!!");
- }
- }
- }
复制代码 |