@@ -39,11 +39,11 @@ Using the [Java Exception Handling documentation][4] as a guide, implement the m
3939Create a method that performs division while handling potential arithmetic exceptions:
4040
4141``` java
42- public Double divide(Double numerator, Double denominator) {
42+ public Integer divide(Integer numerator, Integer denominator) {
4343 // TODO: Implement this method to divide the numerator by the denominator
44- // - return the result of the division
45- // - if the denominator is 0, catch the ArithmeticException and return null
4644 // - if either parameter is null, return null
45+ // - catch the ArithmeticException thrown when the denominator is 0 and return null
46+ // - return the result of the division
4747 throw new RuntimeException (" Not implemented" );
4848}
4949```
@@ -111,8 +111,8 @@ public String processData(List<String> data, int index) {
111111ExceptionExercises exercises = new ExceptionExercises ();
112112
113113// Safe division
114- Double result1 = exercises. divide(10.0 , 2.0 ); // Returns 5.0
115- Double result2 = exercises. divide(10.0 , 0. 0 ); // Returns null (handles ArithmeticException)
114+ Integer result1 = exercises. divide(10 , 2 ); // Returns 5
115+ Integer result2 = exercises. divide(10 , 0 ); // Returns null (handles ArithmeticException)
116116
117117// Safe list access
118118List<Integer > numbers = Arrays . asList(1 , 2 , 3 , 4 , 5 );
0 commit comments