1.代码:
package com.example.interfaceInnerClass;
public class test {
public static void main(String[] args) {
Test1.A a = new Test1.A();//实例化
Test1.B b = new Test1.B();
Test1.C c = new Test1.C();
c.hh();
System.out.println(a.a);
System.out.println(b.b);
new Test1.C();
a.Say();
System.out.println("---------------");
Sun sun = new Sun();
sun.method();
sun.methodB();
sun.methodC();
}
}
interface Test1{
void hh();
class A{
public int a=1;
//说
public void Say(){
System.out.println("你好,我是接口内部类的A帅哥");
}
}
class B{
public int b=2;
}
class C implements Test1{
public int c=3;
public void hh() {
System.out.println("哈哈"+c);
}
}
}
class Sun implements Test1{
void method(){
System.out.println(new A().a);
}
void methodB(){
System.out.println(new B().b);
}
public void hh() {
System.out.println("哈哈,我是hh,我被实现了");
}
void methodC(){
C c = new C();
c.hh();
}
}
2.反思总结:
图解:接口内部类可以实例化