For the primitive types: int, double, short, etc…
Given:
String typeName = "double";
How do I get double.class?
For a regular class we can do the following:
String typeName = "java.lang.Integer"
Class<?> clazz = Class.forName(typeName);
// Class.forName(typeName) returns Double.class
You can’t do that. Check out the reflection documentation. Go to the “Class.forName()” section and there, you can find a note:
One option might be to create a method that will recognize the primitive types and return the matching class (i.e. Integer.class, Double.class, etc…)