java - Why can't I implement a parametrized interface mutiple times with different parameters? -


i'm developing system widgets listen changes in model. wanted notify widgets on interface parametrized notification's class. why doesn't java allow this:

public class uiinventory extends widget implements      observer<eventgetitem>,      observer<eventloseitem>,      observer<eventwield>,      observer<eventunwield>,      observer<eventputon>,      observer<eventtakeoff> { 

the error message duplicate class: 'my.package.structure.observer', why appear in first place?

the answer lies in java's type erasure. @ runtime, generic type information erased, , result in

public class uiinventory extends widget implements    observer,    observer,    observer,    observer,    observer,    observer { 

which cannot do. generic type parameters in methods resolve object , you'd duplicate method signatures.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -