Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| programmierung:interfaces [2025/05/01 13:58] – swe | programmierung:interfaces [2025/12/20 14:53] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 46: | Line 46: | ||
| - | ### Attribute | + | ### Attri |
| + | bute | ||
| - | Ein Interface | + | Falls überhaupt, |
| - | - `static`, d.h. das Attribut ist eine sog. Klassenvariable und gilt | + | - `public`, d.h., das Attribut ist von überall zugreifbar |
| + | - `static`, d.h. das Attribut ist eine sog. Klassenvariable und gilt | ||
| über alle Instanzen der Klasse hinweg | über alle Instanzen der Klasse hinweg | ||
| - `final`, d.h. das Attribut ist nicht veränderbar - sprich: es ist | - `final`, d.h. das Attribut ist nicht veränderbar - sprich: es ist | ||
| Line 62: | Line 64: | ||
| ## Verwendung | ## Verwendung | ||
| - | Interfaces verwenden | + | Interfa |
| + | ces verwe | ||
| + | nden das Schlüsselwort `interface`. | ||
| Eine Klasse, die das Interface implementiert, | Eine Klasse, die das Interface implementiert, | ||
| Line 73: | Line 77: | ||
| public interface Saeugetier{ | public interface Saeugetier{ | ||
| | | ||
| - | | + | // Deklarierung von Konstanten (public, static, final muss nicht explizit angegeben werden!) |
| + | // Wichtig: Muss initialisiert werden | ||
| + | public boolean HATLUNGE= true; | ||
| // Methoden ohne Implementierung | // Methoden ohne Implementierung | ||