Can't declare an abstract method private

前端 未结 6 1609
再見小時候
再見小時候 2020-12-11 00:31

I want to do this, yet I can\'t. Here is my scenario and rational. I have an abstract class for test cases that has an abstract method called test(). The test() method is to

6条回答
  •  清歌不尽
    2020-12-11 01:13

    I'd like to point out that it is the choice of Java not to let abstract private methods implemented (e.g. in C++ you can and is advisable). Saying that private methods are not polymorphic in general is just ignorant of the fact that calling and defining a method is two different mechanism - although subclasses can never call a private method of a superclass, they could be able to define it. Mixing the two is a common misconception, please be aware.

    I don't have enough reputation to comment, that's why I'm writing an answer.

提交回复
热议问题