| Gehe zu : abstract | Gehe zu : boolean |
"Assertions" sind Erklärungen im Sinne von Vor- bzw. Nachbedingungen ans Programm, die den Code hart abbrechen lassen können. (Seit JDK 1.4)
public double myAbs(double x)
{
x = radius * Math.abs(x); // or some more complicated code here
assert x >= 0; // postcondition
return x
}
public double setRadius(double x)
{
this.radius = x;
assert x >= 0 : "Kein negativer Radius moeglich!"; // postcondition
return x
}