How do I provoke an error so that the exc.printStackTrace(System.out);
is displayed when I run the program:
public String getName(){
try {
if(haveName()) return Name;
else {
throw new CorrectNameException("no name");
}
} catch (ExistException e) {
return e.getExc();
} catch (CorrectNameException exc) {
exc.printStackTrace(System.out);
return "nameless";
}
}
Make haveName()
return false. Simple.