Java7 : Multiple Catch Block with example


With JAVA SE 7, Multi-catch exceptions handling has been introduced and it is a convinent way for exception handling, since we can catch multiple exceptions using one catch block.

In the "Multi-catch" block each exception should be separated by pipe (|) charatcter and that will make code is more readable.

Read more : Working with Java SE 7 

Ex:
public class SampleClass {
 public static void main(String[] args) {
  try {
   // Your code
  } catch (ParseException | IOException exception) {
   // inside the multie catch block
  }
 }
} 

Comments

Popular posts from this blog

XSLT - Modify Date and DateTime value

Integrate With Mutual Certificate Authentication based Service

Yield Price Sri Lanka - Android Application