hlapointe
hlapointe

Reputation: 117

Unexpected bound

I'm trying to compile this new class :

public class WindowedGame
        extends GameContainer<GameType extends Game<Graphics2D>> {
    ...
}

This class extends the class :

public abstract class GameContainer<GameType extends Game<?>> {
    ....
}

Can you suggest me a correction or explain to me why I get the error :

Unexpected bounds

Thanks!

Upvotes: 7

Views: 19890

Answers (1)

Eran
Eran

Reputation: 393791

GameType is the generic type parameter name, so it cannot be in the extends clause.

If WindowedGame should be generic, define it as

public class WindowedGame<GameType extends Game<Graphics2D>>
        extends GameContainer<GameType> {
    ...
}

If WindowedGame shouldn't be generic, perhaps you meant to define it as

public class WindowedGame
        extends GameContainer<Game<Graphics2D>> {
    ...
}

BTW, the naming convention for generic type parameter names is often a single upper case character (T, E, etc...). It would be less confusing if instead of GameType you write T.

public class WindowedGame<T extends Game<Graphics2D>>
        extends GameContainer<T> {
    ...
}

public abstract class GameContainer<T extends Game<?>> {
    ....
}

Upvotes: 13

Related Questions