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.
public int power(int x, int y) throws Exception{
if(x < 0 || y < 0){
throw new Exception("n and p should be non-negative");
}
else{
return (int)Math.pow(x,y);
}
}
Day 17: More Exceptions
You are viewing a single comment's thread. Return to all comments →
Java Solution: