先用javac编译,带参数-d
javac -d . ****.java
然后,在当前目录下(不要到****子目录),运行java即可。
java ***.*****
如:
javac -d . FuctionDemo2.java
java com.FuctionDemo2
package com; import java.util.function.Function; public class FuctionDemo2 { public static void main(String[] args) { convert("张三,30",s -> s.split(",")[1],Integer::parseInt,integer -> integer+70); convert("张三,30",s -> Integer.parseInt(s.split(",")[1]),integer -> integer+70); convert("张三,30",s -> Integer.parseInt(s.split(",")[1])+70); } public static void convert(String s, Function<String,String>fun1,Function<String ,Integer>fun2,Function<Integer,Integer>fun3){ Integer apply = fun1.andThen(fun2).andThen(fun3).apply(s); System.out.println(apply); } public static void convert(String s, Function<String,Integer>fun1,Function<Integer ,Integer>fun2){ Integer apply = fun1.andThen(fun2).apply(s); System.out.println(apply); } public static void convert(String s, Function<String,Integer>fun1){ Integer apply = fun1.apply(s); System.out.println(apply); } }
示例来源:JAVA中Function的使用 - phpwyl - 博客园 (cnblogs.com)
标签:convert,java,package,编译,static,Integer,apply,public From: https://www.cnblogs.com/jizhong/p/16853311.html