/*
package com.__01Study.javase.inner;
public interface TV {
void seeSome(double a,double b);
}
*/
/*
package com.__01Study.javase.inner;
public class Staff {
public void useTVWorking(TV tv,double n,double m){
tv.seeSome(n,m);
}
}
*/
package com.__01Study.javase.inner;
public class StaffTest {
public static void main(String[] args) {
Staff jack = new Staff();
double a = 34.5;
double b = 23.5;
jack.useTVWorking(new TV() {
@Override
public void seeSome(double a, double b) {
double result = a+b;
System.out.println(result);
}
}, a, b);
}
}
/*匿名内部类小结
1.匿名类对象就是没有名称类型的对象
2.匿名类对象经常作为接口或抽象类的实现
3.匿名类对象可以减少接口或者抽象类实现类的定义
4.匿名类对象一定属于实现它实现的父类
*/
匿名内部类使用
最新推荐文章于 2024-08-18 23:25:39 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)