Java Short Array Convert To copySignedShortToIntArray(short[] src)

Here you can find the source of copySignedShortToIntArray(short[] src)

Description

Copy an array of signed values in short, into an array of int.

Sign extension is performed.

License

Open Source License

Parameter

Parameter Description
src an array of short, whose values are interpreted as signed

Return

an array of int

Declaration

static public int[] copySignedShortToIntArray(short[] src) 

Method Source Code

//package com.java2s;

public class Main {
    /**/* w  w w  .  j  av a 2  s  . co m*/
     * <p>Copy an array of signed values in short, into an array of int.</p>
     *
     * <p>Sign extension is performed.</p>
     *
     * @param   src   an array of short, whose values are interpreted as signed
     * @return      an array of int
     */
    static public int[] copySignedShortToIntArray(short[] src) {
        if (src == null)
            return null;
        int n = src.length;
        int[] dst = new int[n];
        for (int j = 0; j < n; ++j) {
            dst[j] = src[j]; // allow sign extension
        }
        return dst;
    }
}