JDK8新特性☞Function测试

来源:互联网 发布:传奇盛世翅膀8升9数据 编辑:程序博客网 时间:2024/04/28 23:40
/**
 * JDK8新特性☞Function接口测试 Function接口有一个参数并且返回一个结果,并附带一些和其他函数组合的默认方法
 * 
 * @author Administrator
 *
 */
public class Test1 {
public static void main(String[] args) {
Function<Integer, String> function = String::valueOf;
Function<Integer, Integer> then = function.andThen(Integer::valueOf);
Integer apply = then.apply(123);
System.out.println(apply);
}

}

测试结果


123

原创粉丝点击