2015-04-20 15:36:01 -07:00
|
|
|
|
//: generics/SimpleDogsAndRobots.java
|
2015-05-29 14:18:51 -07:00
|
|
|
|
// <20>2015 MindView LLC: see Copyright.txt
|
2015-04-20 15:36:01 -07:00
|
|
|
|
// 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!
|
|
|
|
|
*///:~
|