is Class Primitive Type - Android java.lang.reflect

Android examples for java.lang.reflect:Class

Description

is Class Primitive Type

Demo Code


//package com.java2s;

public class Main {
    public static boolean isPrimitiveType(Class<?> type) {
        if (type.isPrimitive()) {
            return true;
        }/*from   w w  w  . j  av a 2  s  .  co m*/
        if (type == Boolean.class) {
            return true;
        }
        if (type == Character.class) {
            return true;
        }
        if (type == Byte.class) {
            return true;
        }
        if (type == Short.class) {
            return true;
        }
        if (type == Integer.class) {
            return true;
        }
        if (type == Long.class) {
            return true;
        }
        if (type == Float.class) {
            return true;
        }

        return type == Double.class;
    }
}

Related Tutorials