Any way to extend two or more classes in java?

前端 未结 12 1456
再見小時候
再見小時候 2021-01-17 02:20

I know that Java does not allow us to extend more than one class. I know that interfaces also exist and I don\'t want to use them this time. Is there some kind of trick or w

12条回答
  •  野的像风
    2021-01-17 02:45

    You can do it easily with interfaces and composition.

    The question is why you would ask such a thing? Why do you not want to use interfaces "at this time"?

    You have to know that Java only allows single inheritance of implementation. You've spent seven months at SO, so surely you must know how to use the search feature. The question has been asked here repeatedly.

    Be more creative. There's no reason that a JPanel has to be Observable. JPanel is for rendering. I agree that its model data might want to be Observable. By all means do it with composition.

提交回复
热议问题