简单的函数式接口测试

package t1;

public class Lambda {

public static void main(String[] args) {
Functiuon<Integer, Integer> square = x -> x * x;
Functiuon<Integer, Integer> trip = x -> x * 3;
System.out.println(square.apply(2));
System.out.println(trip.apply(2));
}

}

interface Functiuon<T, U> {

U apply(T t);
}

执行结果:

猜你喜欢

转载自www.cnblogs.com/dengw125792/p/12573011.html