Here's a simple example:
class World<S extends Sprites, B extends Bodies> {
// Both of these have a problem...
static World world = null; // "World is a raw type. References to generic type
// World<BOD,SPRT> should be parameterized"
static World<S, B> world = null; // "Cannot make a static reference to the non-static type S
// "Cannot make a static reference to the non-static type B
// The following is allowed but looks ugly/fishy to me
static World<?, ?> world = null; //
In case you are wondering, I am trying to get a singleton pattern going. The challenge is that this class is extended in a separate package GAME , and I cannot have this package (MODEL) have any dependency on that GAME. Therefore the constructor has to be MODEL. So it would be OK to have the Constructor store the singleton object in the static variable of this class in MODEL.
Is the static World<?, ?> world = null;
indeed ugly in your opinion and is there a better way to approach this?