Function接口练习之按照要求操作数据

package LambdaTest.LambdaTest05;

import java.util.function.Function;

/**
 * FileName: FunctionTest02
 * Author:   lps
 * Date:     2022/4/9 20:32
 * Sign:刘品水 Q:1944900433
 */
public class FunctionTest02 {
    public static void main(String[] args) {
        String s = "刘品水,15";
        convert(s, ss -> ss.split(",")[1], ss -> Integer.parseInt(ss), ss -> ss + 6);


    }

    private static void convert(String s, Function<String, String> fun1, Function<String, Integer> fun2, Function<Integer, Integer> fun3) {
        Integer i = fun1.andThen(fun2.andThen(fun3)).apply(s);
        System.out.println(i);
    }
}

 

posted @ 2022-04-09 20:56  刘品水  阅读(19)  评论(0编辑  收藏  举报