T
T
Tsuzukeru2019-10-30 12:12:46
Java
Tsuzukeru, 2019-10-30 12:12:46

Why throw an exception to the top for the main method?

Hello. Please explain why exceptions are thrown up in the main method?

public class App {
    public static void main(String[] args) throws Exception {
    }
}

There is a rule - declare or process an exception. If we add to the throws method, then must we process it in a try catch when called? But we do not call the main method from another method.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
roswell, 2019-10-30
@roswell

Exception will fall into the JVM, no more, no less, everything is simple here. The rest depends on the purpose for which the exception is thrown from main.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question