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

Method main

streams/FunctionMap.java:21–37  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

19 .forEach(System.out::println);
20 }
21 public static void main(String[] args) {
22
23 test("add brackets", s -> "[" + s + "]");
24
25 test("Increment", s -> {
26 try {
27 return Integer.parseInt(s) + 1 + "";
28 } catch(NumberFormatException e) {
29 return s;
30 }
31 });
32
33 test("Replace", s -> s.replace("2", "9"));
34
35 test("Take last digit", s -> s.length() > 0 ?
36 s.charAt(s.length() - 1) + "" : s);
37 }
38}
39/* Output:
40 ---( add brackets )---

Callers

nothing calls this directly

Calls 2

testMethod · 0.95
replaceMethod · 0.80

Tested by

no test coverage detected