Here is my generic class:
class MultiType<T> {
private T value;
MultiType(T value) {
this.value = value;
}
T get() {
return value;
}
}
At the moment, I can obviously invoke it with:
MultiType multi = new MultiType<Integer>(0);
Or:
MultiType multi = new MultiType<String>("Hello, World");
However, I want to know if the type can be dynamically set by a variable. I know the below doesn't work, but something along the lines of that is what I am looking for:
Class strType = "".getClass();
MultiType multi = new MultiType<strType>("Hello, World");
Thanks in advance.