| Java™ und Objektorientierung | |
| Java/OO |   Druckversion | 
 
| Gehe zu : this | Gehe zu : throws | 
Eine Ausname (Exception) wird auf den Exception-Stack geworfen. Die aufrufende Methode fängt diese Exception ab (catch) oder schickt sie weiter an ihre eigene aufrufende Methode (throws).
  public class Kreis {
    private float radius;
    public Kreis(float r) throws ArithmeticException {
      if (r < 0.0) {
        throw new ArithmeticException("Radius negativ!");
      }
      this.radius = r;
    }
  }