Answer the question
In order to leave comments, you need to log in
Java Collections abstract type List?
Good afternoon. Please help me to understand the basic question.
Java collections have an abstract List class, from which the basic data structures are inherited.
In all the sources that I came across, it is said that you cannot create a direct instance of the List class.
However, when working with code, I encounter constructions like
public List<MyDataClass> myMethod(){
return List<MyDataClass>}
Answer the question
In order to leave comments, you need to log in
Google about the essence and meaning of OOP.
An object of an abstract class cannot be created. It is abstract because it is "underdetermined" and assumes that everything that needs to be done in descendant classes will be completed.
A variable of type List can point to an object of any child class.
ps
What is said above, to one degree or another, applies to any language that implements the concept of OOP (specific implementation details in different languages \u200b\u200bmay differ slightly, but the essence remains unchanged)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question