你可以在Java扩展的ArrayList? [英] Can you extend ArrayList in Java?
本文介绍了你可以在Java扩展的ArrayList?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
时有可能使扩展ArrayList的子类?如果是这样,怎么样?
Is it possible to make a child class that extends ArrayList? If so, how?
推荐答案
您可以扩展任何类,不是的最后在Java中。说了这么多,你应该避免继承如果没有真正是-A 的关系。考虑重用组成。阅读关于里氏替换原则
You can extend any class that is not final in Java. Having said that, you should avoid inheritance if there is no true is-a relationship. Consider composition for reuse. Read about Liskov substitution principle
这篇关于你可以在Java扩展的ArrayList?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文