That code looks good to me. More important, it compiles :-)
Toke Noer wrote:
Can't say I like the syntax for getting the iterator though. I wish it was just:
But that won't compile for me.
There has to be extra syntax, though. There is a real difference between guaranteeing every object in the collection is of the exact type X, and guaranteeing every object in the collection is either of type X or some sub-type of X. So there would need to be different syntax to indicate the two situations:
1) all objects in the collection are of the exact type X ==> Iterator<X>
2) all objects in the collection are assignable to the type X ==> Iterator<? extends X>
I guess it could have been less wordy, but on the other hand it is rather expressive so it works well in a language like
Java which tends to favor readability at the cost of wordiness over pithiness at the cost of readability.