23 lines
470 B
Java
23 lines
470 B
Java
|
//: generics/SimpleDogsAndRobots.java
|
|||
|
// <20>2015 MindView LLC: see Copyright.txt
|
|||
|
// Removing the generic; code still works.
|
|||
|
|
|||
|
class CommunicateSimply {
|
|||
|
static void perform(Performs performer) {
|
|||
|
performer.speak();
|
|||
|
performer.sit();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public class SimpleDogsAndRobots {
|
|||
|
public static void main(String[] args) {
|
|||
|
CommunicateSimply.perform(new PerformingDog());
|
|||
|
CommunicateSimply.perform(new Robot());
|
|||
|
}
|
|||
|
} /* Output:
|
|||
|
Woof!
|
|||
|
Sitting
|
|||
|
Click!
|
|||
|
Clank!
|
|||
|
*///:~
|