How do I check if a class represent a primitive type?
Category: java.lang.reflect, viewed: 4K time(s).
Java uses class objects to represent all eight primitive types. A class object that represents a primitive type can be identified using the isPrimitive() method call. void is not a type in Java, but the isPrimitive() method returns true for void.class.
Here is the result of the program:
int is a primitive type. java.lang.String is not a primitive type. double is a primitive type. void is a primitive type.