mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-26 06:48:04 +02:00
Added source files (Programmieren Tutorium)
This commit is contained in:
parent
1be8f17cc0
commit
ad81fa802b
244 changed files with 8252 additions and 0 deletions
24
presentations/Programmieren-Tutorium/Tutorium-10/Animal.java
Normal file
24
presentations/Programmieren-Tutorium/Tutorium-10/Animal.java
Normal file
|
@ -0,0 +1,24 @@
|
|||
public static class Animal {
|
||||
public String toString() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
}
|
||||
public static class Rat extends Animal {}
|
||||
public static class Lion extends Animal {}
|
||||
public static class Cage<T extends Animal> {
|
||||
/* above */
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Cage<Animal> animals = new Cage<Animal>();
|
||||
Cage<Lion> lions = new Cage<Lion>();
|
||||
|
||||
// OK to put a Rat into a Cage<Animal>
|
||||
animals.add(new Rat());
|
||||
|
||||
lions.add(new Lion());
|
||||
|
||||
// invoke the super generic method
|
||||
lions.transferTo(animals);
|
||||
animals.showAnimals();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue