Bookmark Topic Watch Topic
  • New Topic

Exception Handing

 
Ma JianHui
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Report post to moderator
public class Plane {
static String s = "-";

public static void main(String[] args) {
new Plane().s1();
System.out.println(s);
}

void s1() {
try{
s2();
}catch(Exception e) {
s +="c";
}
}

void s2()throws Exception {
s3(); s +="2";
s3(); s +="2b";
}

void s3() throws Exception {
throw new Exception();
}

}


The output is : "-c",what is going on?
Please help me!Thanks!
 
Anubhav Anand
Ranch Hand
Posts: 341
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please avoid posting the same query more than once as it wastes time.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!