| Author |
List interface in Collection Framework
|
Ajay Singh Rathore
Greenhorn
Joined: Nov 20, 2007
Posts: 2
|
|
can anyone explain this syntax. List<List<Integer>> table = new ArrayList<List<Integer>>(); what is the meaning of this syntax.
|
 |
Santhi Bharath
Ranch Hand
Joined: Jun 03, 2008
Posts: 75
|
|
up to my knowledge that is list of integer lists. tables list contains lists of integers
|
thanks and regards<br />Santhi Bharath<br />SCJP 5.0, SCWCD 5.0
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
Hi Ajayr! Welcome to Javaranch. Santhi is right. your reference variable table is a list of integer lists. Lets take a more meaningful example to understand this- List<List<Planet>> solarSystems = new List<List<Planet>>(); so here we have a list of solar systems, where each solar system has a list of planets. You can add elements to this list as follows List<Planet> sun = new List<Planet>(); sunPlanets.add(new Planet("Mercury")); sunPlanets.add(new Planet("Venus")); sunPlanets.add(new Planet("Earth")); solarSystems.add(sun); List <Planet> dogStar = new List<Planet>(); dogStar.add(new Planet("MyPlanet1")); dogStar.add(new Planet("MyPlanet2")); solarSystems.add(dogStar);
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
Rekha Srinath
Ranch Hand
Joined: Sep 13, 2008
Posts: 178
|
|
|
More than the theoretical explanation, the code looks more understanding...Thanks Ankit !!!
|
 |
 |
|
|
subject: List interface in Collection Framework
|
|
|