MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / FunctionComposition

Class FunctionComposition

functional/FunctionComposition.java:7–20  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5import java.util.function.*;
6
7public class FunctionComposition {
8 static Function<String, String>
9 f1 = s -> {
10 System.out.println(s);
11 return s.replace('A', '_');
12 },
13 f2 = s -> s.substring(3),
14 f3 = s -> s.toLowerCase(),
15 f4 = f1.compose(f2).andThen(f3);
16 public static void main(String[] args) {
17 System.out.println(
18 f4.apply("GO AFTER ALL AMBULANCES"));
19 }
20}
21/* Output:
22AFTER ALL AMBULANCES
23_fter _ll _mbul_nces

Callers

nothing calls this directly

Calls 1

replaceMethod · 0.80

Tested by

no test coverage detected