- public class Main implements T.TIN{//实现了一个内部接口
- public static void main(String[] args) {
- new T().new TI().f();
- new Main().f();
- }
- @Override
- public void f() {
- System.out.println("I'm in a function which in Class Main");
- }
- }
- class T{
- class TI implements TIN{//内部类,实现了一个内部接口
- @Override
- public void f() {
- System.out.println("I'm in a function which in a Inner Class of Class T");
- }
-
- }
- interface TIN{//内部接口,没有定义成私有的,外部可访问,即可实现此接口
- void f();
- }
- }
- 输出:
- I'm in a function which in a Inner Class of Class T
- I'm in a function which in Class Main
复制代码 |