Java Reflection calling constructor with primitive types

Use Integer.TYPE instead of Integer.class.

As per the Javadocs, this is “The Class instance representing the primitive type int.”

You can also use int.class. It’s a shortcut for Integer.TYPE. Not only classes, even for primitive types you can say type.class in Java.

Leave a Comment