Thursday, January 31, 2019

final method in int

package com.concretepage;
public class finalMethodInInt {
public static void main(String[] args) {
System.out.println(riskyAction(1));
System.out.println("-----------");
System.out.println(riskyAction(2));
}
public static int riskyAction(int greeting){
try{
if(greeting==1) {
System.out.println(greeting + " from try block");
}else{
throw new Exception();
}
System.exit(100);
return 0;
}
catch(Exception e){
System.out.println(greeting + " from catch block");
return 2;
}
finally{
System.out.println("I am fially block");
System.exit(0);
return 3;
}
//return 4;
    }
}

No comments:

Post a Comment