After Java 7 or 8, generics can be omitted within the <> when instantiating. As for list<list>, it should be similar to a two-dimensional array. I wonder if this has been used. Map<string, list<string>> is often used in one-to-many relationships.
Both of the two people above answered the question incorrectly. . . The main question is: 1. Why is the front type List, and the new type at the end is ArrayList? 2. What does it mean that list is nested in list. To be honest, this question is something you can come into contact with in the first week of learning object-oriented. The declared type of results is List, but its actual type is ArrayList. ArrayList is the implementation class of List, which means a subclass. The specific type of results cannot be determined during program compilation. Instead, during runtime, the type is dynamically bound based on the actual type of results. This is called polymorphism. List nested within List means that the elements in this set are still sets one by one.
Isn’t this just that every element of List is still a List. I didn’t write generics later because they can be omitted.
After Java 7 or 8, generics can be omitted within the <> when instantiating.
As for list<list>, it should be similar to a two-dimensional array.
I wonder if this has been used. Map<string, list<string>> is often used in one-to-many relationships.
Both of the two people above answered the question incorrectly. . .
The main question is: 1. Why is the front type List, and the new type at the end is ArrayList? 2. What does it mean that list is nested in list.
To be honest, this question is something you can come into contact with in the first week of learning object-oriented.
The declared type of results is List, but its actual type is ArrayList. ArrayList is the implementation class of List, which means a subclass. The specific type of results cannot be determined during program compilation. Instead, during runtime, the type is dynamically bound based on the actual type of results. This is called polymorphism.
List nested within List means that the elements in this set are still sets one by one.