Why Java 8 ? Improved and new features



According to Oracle, there are more than 9 million Java developers worldwide and more than 3 billion mobile phones run Java.

Java was originally designed for interactive television, but it was too advanced for the digital cable television industry at the time. The language was initially called Oak after an oak tree that stood outside Gosling's office. Later the project went by the name Green and was finally renamed Java, from Java coffee.

Java 8 includes features for productivity, ease of use, improved polyglot programming, security and improved performance.

Features in Java 8 that Will Change How You Code


Lambda expression − Adds functional processing capability to Java.


Method references − Referencing functions by their names instead of invoking them directly. Using functions as parameters.


Default method − Interface to have default method implementation.


Stream API − New stream API to facilitate pipeline processing.


Date Time API − Improved date time API.


Optional − Emphasis on best practices to handle null values properly.


Nashorn, JavaScript Engine − A Java-based engine to execute JavaScript code.


Programming Style

Earlier Versions
Collections.sort(names, new Comparator<String>() {
        @Override
        public int compare(String s1, String s2) {
           return s1.compareTo(s2);
        }
     });


Java 8
Collections.sort(names, (s1, s2) -> s1.compareTo(s2));
Where name is list of strings
  

Comments