Streams, Files, Socket handles database connections, etc. Now in Java 7, you can use try-with-resources feature to automatically close resources, which implements AutoClosable and Closeable interface e.g. Look at this code, how many lines of boiler codes?
See here for more detailed information of how to use String on Switch case statement.īefore JDK 7, we need to use a finally block, to ensure that a resource is closed regardless of whether the try statement completes normally or abruptly, for example while reading files and streams, we need to close them into finally block, which result in lots of boiler plate and messy code, as shown below :īr = new BufferedReader( new InputStreamReader(fin)) Docker Images for OpenJDK Version 8 binaries built by AdoptOpenJDK.
Benefit of using String in switch is that, Java compiler can generate more efficient code than using nested if-then-else statement. } equals() and hashcode() method from is used in comparison, which is case-sensitive. println( "Order is filled") break ĭefault: System. println( "Order is replaced successfully") break Ĭase "FILLED": System. println( "Order is Cancelled") break Ĭase "REPLACE": System. println( "Order is in NEW state") break Ĭase "CANCELED": System. In JDK 7, you can use a String object as the selector. See here for more detailed information on diamond operator in Java.īefore JDK 7, only integral types can be used as selector for switch-case statement.
So you have to type less in Java 7, while working with Collections, where we heavily use Generics. Prior JDK 7, you type more to specify types on both left and right hand side of object creation expression, but now it only needed on left hand side, as shown in below example. I am sure combined with Java 8 lambda expression, these features will result in a much better and cleaner code.ġ0 Best JDK 7 Features Every Java developer should learn There are a couple of good changes on NIO and new File API, and lots of other at the API level, which is also worth looking at. So I took this opportunity to write a summary sort of post to revise these convenient changes and adopt them into our daily programming life. Running Jenkins Java 8 runtime environments are supported in both 32-bit and 64-bit versions Java 11 runtime environments are supported Java 7 and prior are. Though I see programmers using String in Switch and Diamond operator for type inference, again there is very little known about the fork-join framework, catching multiple exceptions in one catch block or using underscore on numeric literals. I don't see automatic resource management used by developers in daily life, even after IDE's has got the content assist for that. 7, when everybody is talking about Java 8? Well I think, not all Java developers are familiar with changes introduced in JDK 7, and what time can be better to revisit an earlier version than before welcoming a new version. Why I am writing this post now? Why I am talking about Java 1. If you remember, Java 6 was nothing on the feature, it was all about JVM changes and performance, but JDK 7 did introduce some cool features which improved the developer's day to day task. But, before you completely delve into Java 8, it’s time to revisit some of the cool features introduced on Java 7. Regarding Oracle Java SE Support Roadmap, version 17, 11 and 8 are the currently supported long-term support (LTS) versions, where Oracle Customers will receive.
We should note that before this long-running project, there were JDK Release Projects that released one feature and then got discontinued.It's been almost a month since Java 8 is released and I am sure all of you are exploring new features of JDK 8. And, just like for the Oracle, the JDK Project will also deliver new feature releases every six months. Initially, it was based only on the JDK 7. But, since Java 10, the open-source reference implementation of the Java SE platform is the responsibility of the JDK Project. Certainly, we should emphasize that the OpenJDK is an official reference implementation of a Java Standard Edition since version SE 7.