Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- catch(Exception exc) { /* won't catch RuntimeException */
- catch(Throwable exc) { /* will catch RuntimeException */
- for(Callback cb : callbacks) {
- try {
- cb.call(item);
- }
- catch(Exception exc) {
- logger.error("Error in callback: ", exc);
- }
- }
- public class Test {
- public static void main(String[] args) {
- try {
- throw new RuntimeException("Bang");
- } catch (Exception e) {
- System.out.println("I caught: " + e);
- }
- }
- }
- I caught: java.lang.RuntimeException: Bang
- catch (Exception ex) { ... }
- class A{//this class will never be initialized because class B won't intialize
- static{
- try{
- classB.someStaticMethod();
- }catch(Exception e){
- sysout("This comment will never be printed");
- }
- }
- }
- class B{//this class will never be initialized
- static{
- int i = 1/0;//throw run time exception
- }
- public static void someStaticMethod(){}
- }
Add Comment
Please, Sign In to add comment