i have one query regarding java standards in case of exception handling.
code snippet:
public String methodXXX(){
//This method may throw IllegalArgumentexception and arrayoutofboundaryException.
}
In this case, Which is good coding standard and please let me know why case1:
public String methodXXX() throw IllegalArgumentexception,ArrayoutofBoundaryException.{
//This method may throw IllegalArgumentexception and arrayoutofboundaryException.
}
case2:
public String methodXXX()throws Exception{
//This method may throw IllegalArgumentexception and arrayoutofboundaryException.
}
Why i am mentioning case2 here is: we might not expect there can be other exception can occur, while run time. As Exception is parent class for all exceptions, case 2 is preferable ??? If yes, in which cases case1 is feasible? Can u please explain me performance point of you also?