@Test public void testRunnable() { Runnable anonymousClass = new Runnable() { @Override public void run() { System.out.println("Executing method run()"); } }; Runnable lambda = () -> System.out.println("Executing method run()"); LambdaExamples.useRunnable(anonymousClass); LambdaExamples.useRunnable(lambda); LambdaExamples.useRunnable(() -> System.out.println("Executing method run()")); }
public static void useRunnable(Runnable runnable){ System.out.println("Before runnable"); runnable.run(); System.out.println("After runnable"); }
LambdaExamples { public static void useRunnable(Runnable runnable){ System.out.println("Before runnable"); runnable.run(); System.out.println("After runnable"); } }
LambdaExamples { public static void useRunnable(Runnable runnable){ System.out.println("Before runnable"); runnable.run(); System.out.println("After runnable"); }  }
LambdaExamples { public static void useRunnable(Runnable runnable){ System.out.println("Before runnable"); runnable.run(); System.out.println("After runnable"); }  static void useRunnable(Runnable runnable); static void useConsumer(Consumer<String> consumer); static String usePredicate(Predicate<String> predicate); static int useFunction(Function<String, Integer> function); }
LambdaExamples { public static void useRunnable(Runnable runnable){ System.out.println("Before runnable"); runnable.run(); System.out.println("After runnable"); }  static void useRunnable(Runnable runnable); static void useConsumer(Consumer<String> consumer); static String usePredicate(Predicate<String> predicate); static int useFunction(Function<String, Integer> function);  }