box the primitive to Wrapper class - Android java.lang.reflect

Android examples for java.lang.reflect:Class

Description

box the primitive to Wrapper class

Demo Code


//package com.java2s;

public class Main {
    /**/*from ww  w .  j  a  va 2s  . c o m*/
     * box the boolean to Boolean
     */
    public static Boolean boxed(boolean v) {
        return Boolean.valueOf(v);
    }

    /**
     * box the char to Character
     */
    public static Character boxed(char v) {
        return Character.valueOf(v);
    }

    /**
     * box the byte to Byte
     */
    public static Byte boxed(byte v) {
        return Byte.valueOf(v);
    }

    /**
     * box the short to Short
     */
    public static Short boxed(short v) {
        return Short.valueOf(v);
    }

    /**
     * box the int to Integer
     */
    public static Integer boxed(int v) {
        return Integer.valueOf(v);
    }

    /**
     * box the long to Long
     */
    public static Long boxed(long v) {
        return Long.valueOf(v);
    }

    /**
     * box the float to Float
     */
    public static Float boxed(float v) {
        return Float.valueOf(v);
    }

    /**
     * box the double to Double
     */
    public static Double boxed(double v) {
        return Double.valueOf(v);
    }

    /**
     * box the given type
     */
    public static <T> T boxed(T v) {
        return v;
    }
}

Related Tutorials