Disabling inherited method on derived class

后端 未结 10 1720
野趣味
野趣味 2020-12-03 06:59

Is there any way to, in a Java derived class, \"disable\" a method and/or field that is otherwise inherited from a base class?

For example, say you have a Shap

10条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-03 07:10

    No.

    • you can pull the method down in only the Circle class (or an interface that is implemented only by that class)
    • you can provide an empty implementations or ones that throw UnsupportedOperationException in the classes that do not support it.

提交回复
热议问题