Android Array to Primitive Type Convert unwrap(Float[] value)

Here you can find the source of unwrap(Float[] value)

Description

Converts an array of Float into an array of float .

License

Apache License

Parameter

Parameter Description
value The array to convert.

Return

The newly created array.

Declaration

public static float[] unwrap(Float[] value) 

Method Source Code

//package com.java2s;
/*//  ww w .jav  a2s.  c  om
 * This source is part of the
 *      _____  ___   ____
 *  __ / / _ \/ _ | / __/___  _______ _
 * / // / , _/ __ |/ _/_/ _ \/ __/ _ `/
 * \___/_/|_/_/ |_/_/ (_)___/_/  \_, /
 *                              /___/
 * repository.
 *
 * Copyright (C) 2013 Benoit 'BoD' Lubek (BoD@JRAF.org)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class Main {
    /**
     * Converts an array of {@link Integer} into an array of {@code int}.
     * 
     * @param value The array to convert.
     * @return The newly created array.
     */
    public static int[] unwrap(Integer[] value) {
        if (value == null)
            return null;
        int[] res = new int[value.length];
        for (int i = 0; i < value.length; i++) {
            res[i] = value[i];
        }
        return res;
    }

    /**
     * Converts an array of {@link Long} into an array of {@code long}.
     * 
     * @param value The array to convert.
     * @return The newly created array.
     */
    public static long[] unwrap(Long[] value) {
        if (value == null)
            return null;
        long[] res = new long[value.length];
        for (int i = 0; i < value.length; i++) {
            res[i] = value[i];
        }
        return res;
    }

    /**
     * Converts an array of {@link Double} into an array of {@code double}.
     * 
     * @param value The array to convert.
     * @return The newly created array.
     */
    public static double[] unwrap(Double[] value) {
        if (value == null)
            return null;
        double[] res = new double[value.length];
        for (int i = 0; i < value.length; i++) {
            res[i] = value[i];
        }
        return res;
    }

    /**
     * Converts an array of {@link Float} into an array of {@code float}.
     * 
     * @param value The array to convert.
     * @return The newly created array.
     */
    public static float[] unwrap(Float[] value) {
        if (value == null)
            return null;
        float[] res = new float[value.length];
        for (int i = 0; i < value.length; i++) {
            res[i] = value[i];
        }
        return res;
    }
}

Related

  1. toPrimitive(Long[] array)
  2. toPrimitive(Long[] array, long valueForNull)
  3. toPrimitive(Short[] array)
  4. toPrimitive(Short[] array, short valueForNull)
  5. unwrap(Double[] value)
  6. unwrap(Integer[] value)
  7. unwrap(Long[] value)