I am having some difficulty creating an array of a Class, where the Class is of a generic type.
Let's take an example function, addOverlay, as follows (assume mapSize is a static class variable):
public void addOverlay(Class<?> dataType) {
dataType[][] d = new dataType[mapSize][mapSize];
overlayMap.add(new Class[mapSize][mapSize]);
}
I get the error, dataType cannot be resolved to a type. This in and of itself doesn't make sense to me, since dataType holds a class type. Still, I tried to insert it directly, with the statement (which gives the same error as before):
overlayMap.add(new dataType[mapSize][mapSize]);
And so on, and so on. I have also tried to use dataType.getClass().
Is there a way in Java to create an array of a class, where the class is a generic type?