ok, das muss ich jetzt verstehen, verstehe es aber nicht so ganz.
ich habe das Ganze jetzt so gemacht..
Ich habe ja keine Throw-Anweisung in meiner main??
die ist doch in der text-Methode von der class Slipsize_too_small_Exception
main
[code=Java]
public class Slipsize_too_small_Exception_Demo {
public static void main(String[] args) throws SlipSizeTooSmallException{
Slipsize_too_small_Exception exception = new Slipsize_too_small_Exception();
exception.text(119);
}
}
[/code]
[code=Java]
public class SlipSizeTooSmallException extends Exception {
public SlipSizeTooSmallException(){
super("Slipsize of your girlfriend is greater than size you typed in");
}
}
[/code]
[code=Java]
public class Slipsize_too_small_Exception{
public void text (int slipSize) throws SlipSizeTooSmallException{
try{
if (slipSize < 120 ){
throw new SlipSizeTooSmallException();
}else{
System.out.println("Successful, great Job");
}
}
catch(SlipSizeTooSmallException e)
{
System.out.println(e.toString() + ": too small slipsize");
}
}
}
[/code]