Java Array From toArray(boolean[] array)

Here you can find the source of toArray(boolean[] array)

Description

to Array

License

Open Source License

Declaration

public static Boolean[] toArray(boolean[] array) 

Method Source Code

//package com.java2s;
/**//from   w  w w  .  j a  v a 2s  .com
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * 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[] toArray(boolean[] array) {
        Boolean[] newArray = new Boolean[array.length];

        for (int i = 0; i < array.length; i++) {
            newArray[i] = Boolean.valueOf(array[i]);
        }

        return newArray;
    }

    public static boolean[] toArray(Boolean[] array) {
        boolean[] newArray = new boolean[array.length];

        for (int i = 0; i < array.length; i++) {
            newArray[i] = array[i].booleanValue();
        }

        return newArray;
    }

    public static Byte[] toArray(byte[] array) {
        Byte[] newArray = new Byte[array.length];

        for (int i = 0; i < array.length; i++) {
            newArray[i] = Byte.valueOf(array[i]);
        }

        return newArray;
    }

    public static byte[] toArray(Byte[] array) {
        byte[] newArray = new byte[array.length];

        for (int i = 0; i < array.length; i++) {
            newArray[i] = array[i].byteValue();
        }

        return newArray;
    }

    public static Character[] toArray(char[] array) {
        Character[] newArray = new Character[array.length];

        for (int i = 0; i < array.length; i++) {
            newArray[i] = Character.valueOf(array[i]);
        }

        return newArray;
    }

    public static char[] toArray(Character[] array) {
        char[] newArray = new char[array.length];

        for (int i = 0; i < array.length; i++) {
            newArray[i] = array[i].charValue();
        }

        return newArray;
    }

    public static Double[] toArray(double[] array) {
        Double[] newArray = new Double[array.length];

        for (int i = 0; i < array.length; i++) {
            newArray[i] = new Double(array[i]);
        }

        return newArray;
    }

    public static double[] toArray(Double[] array) {
        double[] newArray = new double[array.length];

        for (int i = 0; i < array.length; i++) {
            newArray[i] = array[i].doubleValue();
        }

        return newArray;
    }

    public static Float[] toArray(float[] array) {
        Float[] newArray = new Float[array.length];

        for (int i = 0; i < array.length; i++) {
            newArray[i] = new Float(array[i]);
        }

        return newArray;
    }

    public static float[] toArray(Float[] array) {
        float[] newArray = new float[array.length];

        for (int i = 0; i < array.length; i++) {
            newArray[i] = array[i].floatValue();
        }

        return newArray;
    }

    public static Integer[] toArray(int[] array) {
        Integer[] newArray = new Integer[array.length];

        for (int i = 0; i < array.length; i++) {
            newArray[i] = new Integer(array[i]);
        }

        return newArray;
    }

    public static int[] toArray(Integer[] array) {
        int[] newArray = new int[array.length];

        for (int i = 0; i < array.length; i++) {
            newArray[i] = array[i].intValue();
        }

        return newArray;
    }

    public static Long[] toArray(long[] array) {
        Long[] newArray = new Long[array.length];

        for (int i = 0; i < array.length; i++) {
            newArray[i] = new Long(array[i]);
        }

        return newArray;
    }

    public static long[] toArray(Long[] array) {
        long[] newArray = new long[array.length];

        for (int i = 0; i < array.length; i++) {
            newArray[i] = array[i].longValue();
        }

        return newArray;
    }

    public static Short[] toArray(short[] array) {
        Short[] newArray = new Short[array.length];

        for (int i = 0; i < array.length; i++) {
            newArray[i] = new Short(array[i]);
        }

        return newArray;
    }

    public static short[] toArray(Short[] array) {
        short[] newArray = new short[array.length];

        for (int i = 0; i < array.length; i++) {
            newArray[i] = array[i].shortValue();
        }

        return newArray;
    }
}

Related

  1. arrayFromIndex(double[][] values, int index)
  2. arrayFromList(String aList)
  3. arrayFromString(String fromString)
  4. arrayFromString(String s)
  5. arrayFromString(String str)
  6. toArray(CharSequence input)
  7. toArray(Class interfaceClass)
  8. toArray(Double[] array)
  9. toArray(E[] o)