
provide a simple java exception program that uses try , catch, throw and finally blocks.

1)Try/Catch Example:
public class ExceptionExample {
public static void main(String args[]) {
try {
String st="rose";
int num=Integer.parseInt(st);
System.out.println(num);
} catch(Exception ex) {
System.out.println(ex);
}
}
}
2)throw example:
class ExceptionExample
{
public static void main(String[] args) throws Exception
{
String z="Hello";
if(!z.equals("India")){
throw new Exception("No match exception");
}
}
}
For more information, visit the following link:
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.