Java 9 - Try with resources Improvement
Java 9 - Try with resources Improvement In this blog, I’ll discuss about try with resources which was introduced with JDK 7 and what enhancement has been done in JDK 9. Try with resources is a great feature which was introduced in JDK 7 that helps in closing resources automatically after being used. Any class can be used as resources if that class implements AutoClosable Interface. Advantages As try with resources closes all the resources file Automatically which prevents memory leaks. M ore readable code as you don’t have to write unnecessary code. Let’s understand it with an example import java.io.FileNotFoundException; import java.io.FileOutputStream; /** * This class will explain the try with resources which was introduced with * JDK7. * * @author AbdulWaheed18 @gmail.com * */ public class ExmapleWithJava7 { public static void...