Let's see an example;
class ThrowDemo { static void validate(int income) { if(income<30000) throw new ArithmeticException("not able to get loan"); else System.out.println("eligible for getting loan"); } public static void main(String args[]) { validate(18000); } }
Output
Exception in thread "main" java.lang.ArithmeticException: not able to get loan
at ThrowDemo.validate<ThrowDemo.java:6>
at ThrowDemo.main<ThrowDemo.java:12>
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc