Commits

Micha Kops committed 6854fa4

Example for special method references added.

Comments (0)

Files changed (1)

src/com/hascode/tutorial/Main.java

 
         System.out.println("--- @FunctionalInterface example ---");
         new FooExecutor().execFoo((msg) -> System.out.println(msg));
+        
+        System.out.println("--- special method references ---");
+        Predicate<String> namesWithBFilter = namesBeginningWithLetterB::contains;
+        List<String> otherNames = new ArrayList<>();
+        otherNames.add("Zed");
+        otherNames.add("Teddy");
+        otherNames.add("Beth");
+        otherNames.add("Jess");
+        otherNames.stream().filter(namesWithBFilter).forEach(name -> {
+            System.out.println(name);
+        });
+        
     }
 
     private static Optional<Person> computePossiblyWithoutResult(boolean doesWork) {