Reputation: 53129
I have all kinds of GameObject
s. I want to make basic collection definition for them all:
//Wrong number of type arguments; required 2. > expected
public interface GameObjectMap<T> extends Map<String, T extends GameObject> {
}
The collection will allways be mapped by string (because the data are loaded from JSON). But the second generic type argument should be any instance of GameObject
. I have no idea how to write the code above correctly.
Upvotes: 0
Views: 1012
Reputation: 201439
The restriction comes on the first declaration of T
, like
public interface GameObjectMap<T extends GameObject> extends Map<String, T> {
}
Upvotes: 2
Reputation: 484
You're almost right. Simply move the extends GameObject
to the first generic definition:
public interface GameObjectMap<T extends GameObject> extends Map<String, T> {
}
Upvotes: 4