Java Reflection Java Java API
java.lang.Class
public boolean isPrimitive()
Returns true if and only if this class represents a primitive type.
package com.logicbig.example.clazz;public class IsPrimitiveExample { public static void main(String... args) { boolean b = int.class.isPrimitive(); System.out.println(b); b = int[].class.isPrimitive(); System.out.println(b); b = Integer.class.isPrimitive(); System.out.println(b); }}
truefalsefalse
package com.logicbig.example.clazz;public class IsPrimitiveExample2 { public static void main(String... args) { boolean b = void.class.isPrimitive(); System.out.println(b); b = Void.class.isPrimitive(); System.out.println(b); }}
truefalse