/**
* 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);
}
* 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
本文介绍JDK8中Function接口的基本用法及测试案例。Function接口接受一个参数并返回一个结果,支持andThen等方法与其他函数组合使用。示例展示了如何将整数转换为字符串再转换回整数。
8万+

被折叠的 条评论
为什么被折叠?



