String to Int in java - Likely bad data, need to avoid exceptions

前端 未结 16 2126
迷失自我
迷失自我 2020-12-04 18:02

Seeing as Java doesn\'t have nullable types, nor does it have a TryParse(), how do you handle input validation without throwing an exceptions?

The usual way:

16条回答
  •  忘掉有多难
    2020-12-04 18:31

    What's the problem with your approach? I don't think doing it that way will hurt your application's performance at all. That's the correct way to do it. Don't optimize prematurely.

提交回复
热议问题