You are here
Home >

java features after java9

After Java8, Java9 has big changes & new features. Here in this section we will talk about Java Features After Java9. We will update this section on a regular basis on a release of new version. Let’s see Java Features After Java9.

New In Java 10 

1. Local Variable Type Inference : var x=10; allowed but var is not a keyword

var map= new HashMap<String,List<String>>(); is valid
var stream =List.stream(); is valid
var path = Paths.get(filename); is valid
var numbers= List.of(1, 4.5,”Java”); is valid

var s =null is not allowed.
var can’t be defined at class level, can’t be assigned to Lambda expression but can be defined inside lambda expression.
2. Collectors has new method Collectors.unmodifiableList() to control list from modification. Similarly for Set & Map as well.
3. Garbage collector changes.
4. Some methods deprecated.

New In Java 11

Note that from Java 11 Oracle has updated the license term to use only for developing, testing, prototyping, demonstrate your application. You may not use the programs for data processing or any commercial, production or any internal business purposes.
Subscription plan was already in place on yearly or one time payment basis but they have given option of monthly subscription now.
In summary Java is free for personal & non-commercial use always.
Added Features:
1. Collection.toArray(IntFunction) default method
2. Local-variable syntax for Lambda Parameters
Removed features :
1. Com.sun.awt.AWTUtilities class : it was deprecated since jdk8
2. appletViewer Launcher
3. Thread.destroy() & Thread.stop(Throwable)
4. Java EE & CORBA modules

New In Java 12

1. Switch-case Statement : multiple entries allowed as case input

String input=”Monday”;
switch(input) {
case “Monday”, "Tuesday”,”Wednesday”, “Thursday”, “Friday” ->System.out.println(“Week days”);
case “Saturday”, “Sunday” -> System.out.println(“Weekends”);
default -> System.out.println(“Invalid days”);
}

 

2. String literal : HTML code can also be included without any \n character.

String html= “<html>
<body>
<p>Hello World.</p>
</body>
</html>”;

3. Other Garbage Collector & Performance Improvements

New In Java 13 

1. Yield keyword in Switch-case Statement : If we use colon (:) operator, we need to use yield keyword as shown in below code snippet.

String input=”Monday”;
switch(input) {
case “Monday”, "Tuesday”,”Wednesday”, “Thursday”, “Friday” : yield System.out.println(“Week days”);
case “Saturday”, “Sunday” : yield System.out.println(“Weekends”);
default : yield System.out.println(“Invalid days”);
}

 

2. Text block : will be printed exactly as it is written: introduced with triple quote “”” . Now JSON format code can also be inserted without any special character.

String html= “””<html>
<body>
<p>Hello World.</p>
</body>
</html>”””;

New In Java 14

Please visit Java 14 Features

New In Java 15

Please visit Java 15 Features

close

Leave a Reply

Top