Posts

Showing posts from March, 2018

Java 9 - Stream API improvements

Image
Hi, I am Malathi Boggavarapu working at Volvo Group and i live in Gothenburg, Sweden. I have been working on Java since several years and had vast experience and knowledge across various technologies. Stream API improvements Now we learn about Stream API improvements done in java 9. Let's start with the example class Book. It have fields title, authors and price. And we also have methods getBook and getBooks. As their name indicates, getBook method returns a book and getBooks returns list of books. Stream.ofNullable Now we illustrate Stream.ofNullable method. If we see the below code, when we pass null to the ofNullable method of Stream and call count method on it, it returns zero. And when we call getBook method inside ofNullable method, stream returns the count as one. Try the example!! We are going to look at one more example which is more involved. It illustrates the difference in code before and after java 9 - ofNullable

Java 9 - Collection Factory methods

Image
Hi, I am Malathi Boggavarapu working at Volvo Group and i live in Gothenburg, Sweden. I have been working on Java since several years and had vast experience and knowledge across various technologies. Let's jump start into Java 9 features Collection Factory methods Java9 provides some collection factory methods for creating List, Set and Map in more convenient way. Collections: The traditional way 1) Here we use many lines of code to create a small immutable collection of List of books. It is very verbose using the traditional way. List<String> books = new ArrayList<String>(); books.add("Java 9"); books.add("Java 8"); books.add("Java 7"); books.add("Java 6"); 2) There is one more way to create a list of books. We can use Arrays class to create a List.  List<String> books = Arrays.asList("Java 9 Modularity", ..); It's bit weird that you do it using Arrays class. Is

Java 9 - JShell in Action

Image
Hi, I am Malathi Boggavarapu working at Volvo Group and i live in Gothenburg, Sweden. I have been working on Java since several years and had vast experience and knowledge across various technologies. In this tutorial we will learn the most important and useful Java 9 feature JShell. So let's jump into the course. JShell JShell is a command line application bundled with JDK 9. Never before did Java ship with such tool which give immediate feedback on code. You can use JShell to quickly test out new ideas or see what an API in jdk behaves the way you think it does. Regular expressions and also for example data and formatting API's are notorious in this regard. Interactive tweaking is a lot better than the slow added compile and run cycle for these things.  Second Jshell is great way to explore new API's. With code completion and even documentation at tip of your fingers, you can find your way in new API's in minutes. As we have seen these A

Java 9 Modularity - First look

Image
Hi, I am Malathi Boggavarapu working at Volvo Group and i live in Gothenburg, Sweden. I have been working on Java since several years and had vast experience and knowledge across various technologies. Java 9 Modularity - First look Module system is one of the biggest changes to java ever in it's 20  years of existence because modular system does not only effects the language by the new keywords and new features but it also effects the compiler. The compiler needs to know how to translate new features and need to know the module boundaries to enforce them at compile time. Then after the compiler is done, all the method data of the modules is preserved in binary format and loaded by virtual machine. The JVM too should know about modules and modular boundaries and uses this information to ensure reliable configuration of modules together and to enforce modular boundaries again. Tooling needs to change as well for modular system. Think of IDE's and libraries,