| Author |
Java 1.5 typed collections...
|
Tad Dicks
Ranch Hand
Joined: Nov 16, 2004
Posts: 264
|
|
If I make the following declaration: then later do the following Is that legal? does the iterator automatically return an object of the type specified in the angle brackets? if not is this just an oversight or was there a compelling reason for not typing the iterator to what was specified in the collection/list? It seems that its necessary to cast the object coming out of the iterator... or should I be saying for(Iterator<String> = list.iterator....?? -Tad
|
 |
Tad Dicks
Ranch Hand
Joined: Nov 16, 2004
Posts: 264
|
|
|
Ok I guess I just need to ask the question out loud(er type it out) to figure it out... heh.
|
 |
Rick O'Shay
Ranch Hand
Joined: Sep 19, 2004
Posts: 531
|
|
You got it. Side note. Rather than this: ArrayList<String> list = new ArrayList<String>() Do this: List<String> list = new ArrayList<String>() And this: for(String string : list) { ... }
|
 |
 |
|
|
subject: Java 1.5 typed collections...
|
|
|