接口
接口的多态特性,接口多态传递
内部类
内部类的分类-四种内部类
局部内部类的使用
匿名内部类 (重点)
package com.quange.test;
import java.beans.beancontext.BeanContext;
public class test02 {
public static void main(String[] args) {
Cellphone cellphone = new Cellphone();
cellphone.alarmClock(new Bell() {
@Override
public void ring() {
System.out.println("懒猪起床了。。。");
}
});
cellphone.alarmClock(new Bell() {
@Override
public void ring() {
System.out.println("上课了!!!");
}
});
}
}
interface Bell{
void ring();
}
class Cellphone{
public void alarmClock(Bell bell){
System.out.println(bell.getClass());
bell.ring();
}
}
class com.quange.test.test02$1
懒猪起床了。。。
class com.quange.test.test02$2
上课了!!!
进程已结束,退出代码0
成员内部类
静态内部类
评论区