0

What are Locally caught Exceptions in Java?
Whats the dofference between the ones that are caught locally and ones that are not caught locally??

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by nbajordan
0

hmmm to be honest i havent heard of that and had a look on google and nothing popped up. but from what i can gather i think locally caught exceptions are those that are caught within the class itsself, and global would be when the class or object is throwing an exception you have to catch? i might be wrong but to illustrate:

    class X {
    private method1() throws Exception {
    //does an operation that throws an exception
    }
    }
    public class A {
    public static void main(String[] args) {
    X x=new X();
    try {//this is a 'globally' caught exception
    x.method1();
    } catch(Exception ex) {
    ex.printStackTrace();
    }
    }
    }

and a locally caight exception would be:

 class X {
    private method1() {
    try {//this is a locally caught exception
    //does an operation that throws an exception
    } catch(Exception ex) {
    ex.printStackTrace();
    }
    }
    }
    public class A {
    public static void main(String[] args) {
    X x=new X();
    x.method1();

    }
    }

as i said i stand corrected. but as for what is local exceptions there isnt such a thing as far as my knowledge extends

0

class X {
private method1() throws Exception {
//does an operation that throws an exception
}
}
public class A {
public static void main(String[] args) {
X x=new X();
try {//this is a 'globally' caught exception
x.method1();
} catch(Exception ex) {
ex.printStackTrace();
}
}
}
very nice .I like it

:)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.