Android Array Primitive to Object Convert wrap(double[] value)

Here you can find the source of wrap(double[] value)

Description

Converts an array of double into an array of Double .

License

Apache License

Parameter

Parameter Description
value The array to convert.

Return

The newly created array.

Declaration

public static Double[] wrap(double[] value) 

Method Source Code

//package com.java2s;
/*/* w  ww  . ja  v  a  2 s  .co  m*/
 * 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 {@code int} into an array of {@link Integer}.
     * 
     * @param value The array to convert.
     * @return The newly created array.
     */
    public static Integer[] wrap(int[] value) {
        if (value == null)
            return null;
        Integer[] res = new Integer[value.length];
        for (int i = 0; i < value.length; i++) {
            res[i] = Integer.valueOf(value[i]);
        }
        return res;
    }

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

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

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

Related

  1. toObject(double[] array)
  2. toObject(float[] array)
  3. toObject(int[] array)
  4. toObject(long[] array)
  5. toObject(short[] array)
  6. wrap(float[] value)
  7. wrap(int[] value)
  8. wrap(long[] value)
  9. convertToObjectArray(byte[] bytes)