Example & Tutorial understanding programming in easy ways.

What is finally block?

  The finally block in java, if used, is placed after a try block and the catch blocks that follow it. The finally block contains code that will be run whether or not an exception is thrown in a try block.

 As its name shows wheter the exception occur or not the finally code will surely excute. The general syntax looks like this:

public void Method{
   Try {
   // code
   }

   Catch(Exception x) {
   //  code
   }

   Catch(ExceptionClass y) {
   //  code
   }

   finally{
   //this code will be executed whether an exception occurs or not
   //is thrown or caught
   }
}

Read More →
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!