top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Explain Java 7 ARM feature and multi-catch block?

+1 vote
Explain Java 7 ARM feature and multi-catch block?
posted Nov 10, 2017 by Jon Deck

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

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.


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.


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.


try(fis = new FileReader("c:\\\\File.text"){

   //Database operations also

}catch(IOException | SQLException ex){

   //exception handling code

answer Nov 29, 2017 by Manikandan J
Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.