Introduction
- können nicht von String to int casten
- → Übungsstunde
Exceptions werfen
throw new IllegalArgumentException ( "Favourite course must be one of {EProg, EProg}");Beispiel
class Person {
String name; // INV: neither null nor ""
Person(String name) {
if (name == null) {
throw new IllegalArgumentException("name must not be null");
}
if (name == "") {
throw new IllegalArgumentException("name must not be empty");
}
this.name = name;
}
}