Originally posted by Adam Schaible:
When you compile:
public static void main(String[] args...){
}
The compiler changes it to:
public static void main(String[] args...) throws Exception {
}
Originally posted by Adam Schaible:
Essentially the JVM catches your uncaught exceptions, and terminates. Exceptions will "bubble" up the call stack until it's either caught by calling code, or is caught by the jvm.
When you compile:
public static void main(String[] args...){
}
The compiler changes it to:
public static void main(String[] args...) throws Exception {
}
Your calling code then throws the exception to the JVM, it's caught by the JVM, flushed to the error stream, and exits.
Originally posted by Adam Schaible:
De-compile your code, the compiler adds the throws clause.
Originally posted by suresh mulagala:
I was trying to test this...
Leave alone de-compiling..the above code doesnt comile in the first place..so whats this thing adding to the main method meant???![]()
Originally posted by Jesper Young:
Anything that extends Throwable (exceptions, errors etc.) can be thrown by your own application with the "throws" keyword. There isn't a special set of exceptions that is thrown only by the JVM or only by the application.
Originally posted by Adam Schaible:
De-compile your code, the compiler adds the throws clause.
SCJP 5.0