So I programmed this exception for a lab I'm doing:
public class InvalidDNAException extends Exception{
public InvalidDNAException(String message){
super(message);
}
}
and then tried to put the exception into the class I'm using for the lab
try { for (int i=0;i<nucleo.length();i++){
//code to be implemented later
else throw InvalidDNAException("Invalid DNA String");
}
}
catch(InvalidDNAException e){
System.out.print("Invalid string");
System.exit(0);
}
I keep getting the error:
cannot find symbol
else throw InvalidDNAException("Invalid DNA String");
^
symbol: method InvalidDNAException(String)
location: class DNA
Did I just not create the exception correctly or what can I do to fix this?