❮ Previous Next ❯

Java throw keyword

Let's see an example;

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>


❮ Previous Next ❯


  Tutorials

Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Bhubaneswar-751013
      Email: info@silantechnology.com
      Phone: 0674-2361252
address
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved