OnJava8-Examples/generics/OrdinaryArguments.java
2015-05-29 14:18:51 -07:00

28 lines
661 B
Java

//: generics/OrdinaryArguments.java
// ©2015 MindView LLC: see Copyright.txt
class OrdinarySetter {
void set(Base base) {
System.out.println("OrdinarySetter.set(Base)");
}
}
class DerivedSetter extends OrdinarySetter {
void set(Derived derived) {
System.out.println("DerivedSetter.set(Derived)");
}
}
public class OrdinaryArguments {
public static void main(String[] args) {
Base base = new Base();
Derived derived = new Derived();
DerivedSetter ds = new DerivedSetter();
ds.set(derived);
ds.set(base); // Compiles: overloaded, not overridden!
}
} /* Output:
DerivedSetter.set(Derived)
OrdinarySetter.set(Base)
*///:~