Finally Block in Java
Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java
Program 1
import java.util.*;
import java.io.*;
class Abc
{
int mydivision(int a,int b)
{
int c=0;
try
{
c=a/b;
return c;
}
catch(Exception e)
{
System.out.println(e);
}
finally
{
System.out.println("Bye Bye");
}
return c;
}
}
class TestFinally
{
public static void main(String args[])
{
// Scanner scan=new Scanner(System.in);
// int a,b,c;
// System.out.println("Enter two number");
// a=scan.nextInt();
// b=scan.nextInt();
// Abc A =new Abc();
// c=A.mydivision(a,b);
// System.out.println(c);
}
// try
// {
// c=a/b;
// System.out.println(c);
// }
// catch(Exception e)
// {
// System.out.println(e);
// }
// finally
// {
// System.out.println("Bye Bye");
// }
// System.out.println("Take care....... ");
// }
}
You give me 15 seconds I promise you best tutorials
Please share your happy experience on Google

