D
D
DDwrt1002019-06-03 10:44:36
Java
DDwrt100, 2019-06-03 10:44:36

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>}

And this record makes me feel like I'm missing something.
What kind of animal is this List? And can we create instances of this class? How to manage it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Antony, 2019-06-03
@DDwrt100

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 question

Ask a Question

731 491 924 answers to any question