petrigun·قبل 5 سنوات·discussOP said that we would have to use reflection to make this work in Java, but I think we can also make use of Generic classes: class Pokemon<T extends PokeType> { public T type; public Pokemon(T givenType) { type = givenType; } } and in main(): Normal n1 = new Normal(); Pokemon<Normal> pokemon1 = new Pokemon<>(n1);
and in main():