Whats new in Java 8? Where to start learning?
Last week we saw the new release of Java. Version 8 brings a lot of new features into the language. I think the most important are: - lambda expressions, - default method implementations in interfaces, - new datetime api.
There is also a lot of smaller improvements and additions in the standard library.
I’m a huge fan of the functional programming paradigm and of course I’m very excited about the release. Hope it will be quickly and widely adopted in production. Also the library improvements will make a compelling alternative to popular external libraries like JodaTime and Guava. This is good, because I think everybody were including them, even for small projects.
How to get start with Java 8?
If you want to dig into more details of lambdas in Java 8 check these two articles by Brianz Goetz: - http://cr.openjdk.java.net/~briangoetz/lambda/lambda-state-final.html - http://cr.openjdk.java.net/~briangoetz/lambda/lambda-libraries-final.html
This is now Java (example from the latter)
Pattern pattern = Pattern.compile(\\s+"); Map<String, Integer> wordFreq = tracks.stream() .flatMap(t -> pattern.splitAsStream(t.name)) // Stream<String> .collect(groupingBy(s -> s.toUpperCase(), counting()));
Happy coding with Java 8!