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

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -