Override java generic method in interface -
public <a extends interface1,i extends interface2> method(a a);
this method in interface. when override interface method, can replace i
class implements interface2 parameter a
rejected if subclass of interface1. can interface1 type. when try:
public subtypeofinterface2 method(interface1 a); //fine public subtypeofinterface2 method(subtypeofinterface1 a); // not accepted
why happen?
it's because method needs able handle subtype of interface1. happens if user wants pass different subtype of interface1 method? interface tells user can, implementation of interface disagrees. hence error.
Comments
Post a Comment