9:29 pm - Thursday July 19, 2018

program for finally statement

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

//*@author :CandidJava.com
//*@descriptions : This program explain the function and use of finally statement

class Finalstm{

public static void main(String a[])throws Exception{

//The exception should be define under the Try-Catch-finally block

try{

int i=2,j=2,k=j/i;

System.out.println("k="+k);

}

catch(Exception e){

System.out.println(e);

}

//The finally block is executed at anytime if if throws exception itself

finally{

System.out.println("hello candid");

}

}

}

output

D:\Candid Java\Util\Exception>javac Finalstm.java

D:\CandidJava\Util\Exception>java Finalstm

k=1

hello candid

Filed in: Z-A All Java Codes

No comments yet.

Leave a Reply