Java java.util.function.Function create
import java.util.function.Function; public class Main { public static void main(String[] args) { Function<String, String> newText2 = (testText) -> { String tempStr = ""; for (String part : testText.split(" ")) { tempStr += new StringBuilder(part).reverse().toString() + " "; }/*from www .ja v a 2 s. c o m*/ return tempStr; }; System.out.println(newText2.apply("HELLO WORLD")); } } @FunctionalInterface interface ReverseType { String reverse(String text); }