Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.
Java7 ARM feature uses the concept of "try with resources". The try block now has the syntax of a method wherein the resources that will be acted upon are inserted.
Eg:
FileReader fis;
try(fis = new FileReader("c:\\\\file1.txt")){
//code for reading from file
}catch(IOException ioex){
//handle exception
}
As can be seen above, there is no need to close the resources explicitly in finally block. Java7 takes care of this. So it has reduced the lines of code required and made it easier for the developer.
Multi-catch:
Java7 introduced multi catch statements in which one can use a single catch block to specify multiple exceptions that should be caught separated by pipe operator.
Eg:
try(fis = new FileReader("c:\\\\File.text"){
//Database operations also
}catch(IOException | SQLException ex){
//exception handling code
}