handling multiple exceptions in java code example
Example 1: java throws multiple exceptions
public class MyClass implements MyInterface {
public void find(int x) throws A_Exception, B_Exception{
----
----
---
}
}
Example 2: Java catch multiple exceptions and rethrow exception
try
{
}
catch(SQLException | IOException e)
{
logger.log(e);
}
catch(Exception e)
{
logger.severe(e);
}
Example 3: Java catch multiple exceptions and rethrow exception
try
{
}
catch(SQLException e)
{
logger.log(e);
}
catch(IOException e)
{
logger.log(e);
}
catch(Exception e)
{
logger.severe(e);
}