java - Why can't I implement a parametrized interface mutiple times with different parameters? -
this question has answer here:
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
Post a Comment