Any way to extend two or more classes in java?

前端 未结 12 1536
再見小時候
再見小時候 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:59

    Multiple inheritance adds complexity with little benefits, that's why it is not present in java Why is Multiple Inheritance not allowed in Java or C#?

    One way I can think of is to write your program needing multiple inheritance in a language that supports it e.g.C++ and then make your Java code interact with the output from that program e.g using files or databases.

提交回复
热议问题