I'm using the IDE Netbeans7.3 to develop in Java. There is something strange that I cannot explain to myself, so please, help me to understand.
I declared to classes. The first inherits from Exception:
public class MyParameterException extends Exception{        
    public MyParameterException(){
        super();
    }        
    public MyParameterException(String message){
        super(message);
    }
}
and the second inherits from NullPointerException:
public class NullMyParameterException extends NullPointerException{
    public NullMyParameterException(){
        super();
    }        
    public NullMyParameterException(String message){
        super(message);
    }
}
Now, when I create a method in a class and I write:
public void test(String s){
    if(s==null) throw new NullMyParameterException("The input string is null."); 
    if(s.trim().isEmpty()) throw new MyParameterException("The input string is empty.");
}
What seems strange to me is that I get the message unreported exception MyParameterException must be caught or declared to be thrown from the IDE, but nothing is said about the first exception that I could throw in the method.
To my knowledge, the method would expected to be declared as follows:
public void test(String str) throws MyNullParameterException, MyParameterException
but for Netbeans only sufficies:
public void test(String str) throws MyParameterException
Is this:
- An IDE bug.
- Normal because classes that inherits from NullPointerExceptionare special.
- ...
Please, let me understand.
 
     
     
     
    