课程: Java Exception Handling

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Challenge: Handle an ArithmeticException

Challenge: Handle an ArithmeticException - Java教程

课程: Java Exception Handling

Challenge: Handle an ArithmeticException

(electronic music) - [Instructor] We have seen a variety of exceptions so far. And for this challenge, you will have to handle a runtime exception, more specifically the arithmetic exception. This is caused by an invalid arithmetic or mathematical operation, like dividing by zero. For this challenge, I have added yet another end point to find the ratio for a given index and its predecessor. For instance, if the index requested is three, we would retrieve the third number in the Fibonacci sequence, which is two. We would also retrieve the second index in the sequence, which is one, two divided by one is the ratio between the index requested and its predecessor. And the result which is two, is what the end point will return. Why do we care about generating the ratio beyond needing some way to do this challenge and trigger an arithmetic exception? Well the ratio between two consecutive numbers in the Fibonacci…

内容