Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception in main method

 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What if we throw an exception from catch block of main method.. is it take care by JVM? as it comes at the end in the stack, even after throwing exception from it doesn't require to catch it. statements which are made after throw exception work properly. how jvm do it?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15492
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you throw an exception from the main() method, the JVM will catch it and print a stack trace.
 
Parvathi Raju
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The main method will terminate if any exception is occur
 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:If you throw an exception from the main() method, the JVM will catch it and print a stack trace.


it does because of it is the last in stack to end. why won't jvm handle all exception. what are the reasons that we need to handle checked exception?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic