Safe divide
Java
Easy
4 views
Problem Description
Task: divide a by b and throw ArithmeticException when b is 0.
Output Format
Return value
Constraints
Do not return default value on error.
Official Solution
static int safeDivide(int a,int b){if(b==0) throw new ArithmeticException();return a/b;}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!