Java name clash, have the same erasure, neither hides the other

后端 未结 3 1293
无人共我
无人共我 2020-12-10 11:35

I am getting this name clash error and i don\'t know how should i solve the problem. I have two classes and i am using overloaded method \"createSensors\". To simplify here

3条回答
  •  遥遥无期
    2020-12-10 12:23

    The general solution is to use different names. These methods could be in classes without an inheritance relationship as these are not instance methods.

    As pointed out, the method implementation in the question are the same (typo excepted).

    (This issue with overloading is often confused with erasure of runtime types. Overloading is a link-time rather than a dynamic issue, so could be easily fixed in the language. It's just not a particularly useful change, and not a good idea to encourage overloading.)

提交回复
热议问题