Skip to content

Conversation

Cjohns54
Copy link

@Cjohns54 Cjohns54 commented Nov 1, 2024

Updated the division methods to throw an
IllegalArgumentException if the divisor (b) is zero.
Adding error handling for division by zero is crucial to prevent runtime errors and ensure the program fails with a clear error message. This Improves code robustness and user experience.

@@ -3,11 +3,18 @@
public class Division {

public static final long division(int a, int b) {
if (b == 0) {
throw new IllegalArgumentException("Divisor cannot be zero.");
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"I see you changed this to add erroring handling! Great job!"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This addresses the problem of poor error handling by adding this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant