List<ArrayList<Planet>> NAME = new ArrayList<ArrayList<Planet>>(N);
List<List<Planet>> NAME = new ArrayList<ArrayList<Planet>>(N);
ArrayList<ArrayList<Planet>> NAME = new ArrayList<ArrayList<Planet>>(N);
I can't tell what's the difference of these three expressions. I realized later that maybe List is for declaration because its an interface while ArrayList
could be used for initiation, as it is a class. I took the first syntax in my project and find
found : java.util.ArrayList>
required: java.util.ArrayList>
List<List<Planet>> Name = new ArrayList<ArrayList<Planet>>(N);
I have added at the header.
import java.util.ArrayList;
import java.util.List;
In another place, while I am adding Planet
Object into the ArrayList
:
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (i == j) continue;
NAME[i].add(planets[j]);
}
}
The compiler reports,
array required, but java.util.ArrayList> found
planetsForNetForceSetting[i].add(planets[j]);
Could anybody tell me the reason for this?