I'm having an hirarchy like this:
class Foo {
...
}
class Bar extends Foo {
...
}
class Baz extends Foo {
...
}
And now I'm trying to declare an object like this in class foo:
Class<? extends Foo> anyName;
Then there is some method where I want to do this:
anyName = new Foo();
But it won't let me do that. Can anyone help me out?
I've already read several guides/tutorials/documents on generics and wildcards. But I haven't fount quite the solution to this problem.
EDIT: Fixed the capitalization. Sorry that was a typing error. My original classes are indeed like that.
EDIT2: The goal here is to get a singleton-instance of Foo.
EDIT3: I'm really sorry, NOW it should be correct! Shame on me :/