高阶函数与接口混入和java匿名类

高阶函数与接口混入和java匿名类。

高阶函数中的组件(参量)函数相当于面向对象中的混入(接口)类。

public abstract class Bird {
private String name;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public abstract int fly();
}

public static void main(String[] args) {
Test test = new Test();
test.test(new Bird() {

public int fly() {
return 10000;
}

public String getName() {
return "大雁";
}
});
}

 
 
 
原文地址:https://www.cnblogs.com/feng9exe/p/9771185.html