2018-10-19

Java 9 : milling project coin

In Java SE 7, _ were introduced as part of the numbers, whereby a large number could be conveniently written by introducing _ between the digits. This helped in increasing the readability of the number, for example:

Integer large_Number = 123_123_123;
System.out.println(large_Number);

In Java SE 8, the use of _ in the variable names, as shown earlier, resulted in a warning, but in Java SE 9, this use results in an error, which means that the variables
can no longer have _ in their names.

The other changed part of this JEP is to support private methods in interfaces. Java
started with interfaces with absolutely no method implementations. Then, Java SE 8
introduced default methods that allowed interfaces to have methods with
implementations, called default methods. So any class implementing this interface
could choose not to override the default methods and use the implementation
provided in the interface.

Java SE 9 is introducing private methods, wherein the default methods in the
interfaces can share code between them by refactoring the common code into private
methods.
Another useful feature is the allowing of effectively final variables to be used with
try-with-resources. As of Java SE 8, we needed to declare a variable within the try-with-resources block, such as the following:

try(Connection conn = getConnection()){}catch(Exception ex){};

However, with Java SE 9, we can do the following:

try(conn){}catch(Exception ex){}

Here, is effectively final; that is, it has been declared and defined before, and
conn will never be reassigned during out the course of the program execution.

No comments:

Post a Comment