Reputation: 20069
Eclipse complains about this code with "The type parameter Entry is hiding the type Map.Entry":
import java.util.Map.Entry;
public class Test {
static abstract class EntryIterator<Entry<K, V>> implements Iterator<K, V> {
}
}
I don't quite understand what the problem is here - the type in question is java.util.Map.Entry
. How can that shadow itself? How am I supposed to declare the inner class to make it compile?
Upvotes: 0
Views: 189
Reputation: 523474
I think you mean
static abstract class EntryIterator<T extends Entry<?, ?>> implements Iterator<T>
This puts the constrain on the generic parameter T of EntryIterator such that it must be an Entry of something. You create an instance with
new EntryIteartor<Map.Entry<K, V>>(...);
Upvotes: 0
Reputation: 1502016
The problem is this part of the declaration:
class EntryIterator<Entry<K, V>>
That's trying to declare a type parameter called Entry<K, V>
(which isn't valid). You're then saying that the class implements Iterator<K, V>
, which is also invalid as Iterator
only has a single type parameter.
I suspect you actually mean:
class EntryIterator<K, V> implements Iterator<Entry<K, V>>
Upvotes: 4