get Raw Variable Type via getClass() method - Android java.lang.reflect

Android examples for java.lang.reflect:Method Get

Description

get Raw Variable Type via getClass() method

Demo Code


//package com.java2s;

public class Main {
    public static Class<?> getRawVariableType(Object variableClass) {
        Class<?> rawType = variableClass.getClass();
        if (variableClass == Boolean.class) {
            rawType = Boolean.TYPE;
        } else if (variableClass == Byte.class) {
            rawType = Byte.TYPE;//  w ww.  ja v a  2s . c  o m
        } else if (variableClass == Double.class) {
            rawType = Double.TYPE;
        } else if (variableClass == Float.class) {
            rawType = Float.TYPE;
        } else if (variableClass == Integer.class) {
            rawType = Integer.TYPE;
        } else if (variableClass == Long.class) {
            rawType = Long.TYPE;
        } else if (variableClass == Short.class) {
            rawType = Short.TYPE;
        } else if (variableClass == Void.class) {
            rawType = Void.TYPE;
        }
        return rawType;
    }
}

Related Tutorials