Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

Hi Pankaj, Using single catch block how can I differentiate from where my code is getting exception? try{} catch(IOException ie){ ie.printStackTrace();} catch(SQLException se){ se.printStackTrace();} catch(Exception e){ e.printStackTrace();} now it is replaced with catch(IOException| SQLException |Exception e){ e.printStackTrace();} In the above code my doubt is e.printStackTrace() will print which exception class message whether (IOException / SQLException/Exception )?
- subrat panda
Hi Pankaj, if i want to throw different exception message based on exception catched then how to do that? ex: if sql exception then i want send message as failed to insert into table and number excpetion then input provided is not a valid number then how to use single catch block?
- Ashok
Hi pankaj, i really dont understand the code for rethrowing an exception in java7.could you please explain the code in detail.
- indra
i dont understand the throws exception so please pankaj can u explain …
- phintsho
hellow pankaj , can u please explain more abt overloading and overriding… because i always use to get confuse between these two
- phintsho
Hi Pankaj, Note to add here if there is hierarchy of exceptions in catch block then we need to catch base exception only, can’t write child and parent exception in same catch with pipe, it will give compilation error. e.g. catch (IOException | Exception e){} will say IOException already caught by the alternative Exception.
- Tanu
what is the use again we have to re catch exceptions from where we called the method
- Dileep
Write a program which takes the age of 5 persons from command line and find the average age of all persons. The program should handle exception if the argument is not correctly formatted and custom exception if the age is not between 1 to 100.
- siddharth