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

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -