Search code examples
javaarraylistextend

Can you extend ArrayList in Java?


Is it possible to make a child class that extends ArrayList? If so, how?


Solution

  • 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