Type inference in Java 8

Java, version 8, introduced functional programming, with lambda functions. The lambda expression can infer the type of its formal parameters. Consider the following code:

Consumer<String> consumer = (String s) -> System.out.println(s);

 

Instead of the preceding code, you could type the following code:

Consumer<String> consumer = s -> System.out.print(s);
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.97.202