D
D
Danil Ochagov2018-03-04 09:47:38
Java
Danil Ochagov, 2018-03-04 09:47:38

Why use the try/catch signature in java in such an example?

For example, the user must enter only certain numbers, and if he leads another, there will be an error (but the error is not with an exception, but with a try / catch signature so that you can do it yourself).
And why use try / catch here, if the same thing can be done simply by writing what you need in else, or will it be smarter with exception?5a9b9671aca71029478079.png5a9b9677c020b338565092.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2018-03-04
@zagayevskiy

This is bullshit. If in some lessons this is given - run away from there. Throwing an exception, catching something right there, and even in a loop - you have to be a rare idiot. When an exception is thrown, the stack is unrolled, which is expensive.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question