We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Day 17: More Exceptions
Day 17: More Exceptions
Sort by
recency
|
619 Discussions
|
Please Login in order to post a comment
class Calculator{ int n, p; public Calculator(){} public int power(int n, int p) throws Exception{ if(n<0 || p<0) throw new Exception("n and p should be non-negative"); else{ return (int) Math.pow(n,p); } } }
In C#
My 2 cents in Java: