Maybe, you're looking at this pattern (taken from an answer to another question):
private static class SomeContainer<E>
{
E createContents(Class<E> clazz)
{
return clazz.newInstance();
}
}
Here, when we create a SomeContainer
, we parametize the instance with a concrete class (like String
). createContents
will accept String.class
only and String.class.newInstance()
will create a new (empty) String.