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.
More Related Contents:
- How to read the value of a private field from a different class in Java?
- Java Reflection: How to get the name of a variable?
- How to load Classes at runtime from a folder or JAR?
- Creating an instance using the class name and calling constructor
- Run piece of code contained in a String
- What could cause java.lang.reflect.InvocationTargetException?
- How to instantiate an inner class with reflection in Java?
- Printing all variables value from a class
- How to get the fields in an Object via reflection?
- How to call a superclass method using Java reflection
- Invoking a static method using reflection
- Method to dynamically load java class files
- What is the difference between JDK dynamic proxy and CGLib?
- Set private field value with reflection
- How do I access private methods and private data members via reflection?
- Is it possible to create an instance of inner class using Java Reflection?
- How to get the Array Class for a given Class in Java?
- How to have Java method return generic list of any type?
- What is the security risk of object reflection?
- Java Reflection: Getting fields and methods in declaration order
- Difference between Loading a class using ClassLoader and Class.forName
- Java toString() using reflection?
- How to restrict developers to use reflection to access private methods and constructors in Java?
- How to disable Java security manager?
- Java: NoSuchMethodException when method clearly exists
- Java: accessing private constructor with type parameters
- Integer.class vs int.class
- Java casting “.class”-operator used on a generic type, e.g. List, to “Class
- Best way of invoking getter by reflection
- How to use reflection to call a private method from outside a java class without getting IllegalAccessException?