Java Object Array Create toObjectArray(boolean arr[])

Here you can find the source of toObjectArray(boolean arr[])

Description

to Object Array

License

Open Source License

Declaration

public static Boolean[] toObjectArray(boolean arr[]) 

Method Source Code

//package com.java2s;
/**//from ww w  .  j  av a  2 s . c  om
 * JLibs: Common Utilities for Java
 * Copyright (C) 2009  Santhosh Kumar T <santhosh.tekuri@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 */

public class Main {
    public static Boolean[] toObjectArray(boolean arr[]) {
        if (arr == null)
            return null;

        Boolean result[] = new Boolean[arr.length];
        for (int i = arr.length - 1; i >= 0; i--)
            result[i] = arr[i];
        return result;
    }

    public static Character[] toObjectArray(char arr[]) {
        if (arr == null)
            return null;

        Character result[] = new Character[arr.length];
        for (int i = arr.length - 1; i >= 0; i--)
            result[i] = arr[i];
        return result;
    }

    public static Byte[] toObjectArray(byte arr[]) {
        if (arr == null)
            return null;

        Byte result[] = new Byte[arr.length];
        for (int i = arr.length - 1; i >= 0; i--)
            result[i] = arr[i];
        return result;
    }

    public static Short[] toObjectArray(short arr[]) {
        if (arr == null)
            return null;

        Short result[] = new Short[arr.length];
        for (int i = arr.length - 1; i >= 0; i--)
            result[i] = arr[i];
        return result;
    }

    public static Integer[] toObjectArray(int arr[]) {
        if (arr == null)
            return null;

        Integer result[] = new Integer[arr.length];
        for (int i = arr.length - 1; i >= 0; i--)
            result[i] = arr[i];
        return result;
    }

    public static Long[] toObjectArray(long arr[]) {
        if (arr == null)
            return null;

        Long result[] = new Long[arr.length];
        for (int i = arr.length - 1; i >= 0; i--)
            result[i] = arr[i];
        return result;
    }

    public static Float[] toObjectArray(float arr[]) {
        if (arr == null)
            return null;

        Float result[] = new Float[arr.length];
        for (int i = arr.length - 1; i >= 0; i--)
            result[i] = arr[i];
        return result;
    }

    public static Double[] toObjectArray(double arr[]) {
        if (arr == null)
            return null;

        Double result[] = new Double[arr.length];
        for (int i = arr.length - 1; i >= 0; i--)
            result[i] = arr[i];
        return result;
    }
}

Related

  1. toObjectArray(boolean[] primitiveArray)
  2. toObjectArray(byte[] array)
  3. toObjectArray(char... array)
  4. toObjectArray(int[] array)