今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Solution: Handle an ArithmeticException
(upbeat music) - [Instructor] For your challenge you had to handle the potential ArithmeticException that could occur. Since this exception is a RuntimeException, we will not get any helpful hints from a IDE and our application will continue to build. After we see this exception for the first time we have two options, prevent the exception from occurring, through validation, or catching the exception, specifically, and handling it. We will walk through both options in this video. For the first option, which I think is more ideal, we want to validate all values involved. On line 78 we have our divisor, the number we are dividing by, defined as a variable. On the next line after this, line 79, I want to define an if statement, where if the divisor is equal to zero I want to return the String.value of zero for simplicity sake. We, of course, still have the option to return an error message to the user or some kind of other…
内容
-
-
-
-
-
(已锁定)
What are runtime exceptions?2 分钟 28 秒
-
(已锁定)
Runtime exception: Return NumberFormatException to user9 分钟 25 秒
-
(已锁定)
Challenge: Handle an ArithmeticException3 分钟 59 秒
-
(已锁定)
Solution: Handle an ArithmeticException3 分钟 18 秒
-
(已锁定)
Runtime exception: Handling of NullPointerException6 分钟 16 秒
-
(已锁定)
Runtime exception: Unknown runtime exception4 分钟 18 秒
-
(已锁定)
Challenge: Handle potential runtime exceptions1 分钟 19 秒
-
(已锁定)
Solution: Handle potential runtime exceptions4 分钟 1 秒
-
(已锁定)
-