| Author |
for each loop
|
Himalay Majumdar
Ranch Hand
Joined: Sep 28, 2008
Posts: 324
|
|
In the above code due to Autoboxing, by default Integer objects are added to tree, then why in the for each loop I cannot declare and use Integer reference variable . All I can use above is Object and NOT Integer.
|
SCJP 1.6, SCWCD 5.0, SCBCD 5.0 [loading..]
|
 |
Omar Al Kababji
Ranch Hand
Joined: Jan 13, 2009
Posts: 357
|
|
yes because you use TreeSet without any generics so it can take anything not only integers, if you want to use the TreeSet only for Integers then you have to do it like this
|
Omar Al Kababji - Electrical & Computer Engineer
[SCJP - 90% - Story] [SCWCD - 94% - Story] [SCBCD - 80% - Story] | My Blog
|
 |
Himalay Majumdar
Ranch Hand
Joined: Sep 28, 2008
Posts: 324
|
|
|
Thanks Omar
|
 |
 |
|
|
subject: for each loop
|
|
|