Java List to Short Number Array toShortArray(List list)

Here you can find the source of toShortArray(List list)

Description

This converts a list to it's primitive state.

License

Open Source License

Parameter

Parameter Description
list The list to convert

Return

The primitive array instance of the list's contents.

Declaration

public static short[] toShortArray(List<Short> list) 

Method Source Code

//package com.java2s;

import java.util.List;

public class Main {
    /**/* w w  w.  j av  a2 s .c  om*/
     * This converts a list to it's primitive state.
     * In this case, it converts a {@link Short} list to a
     * short array.
     * 
     * @param list The list to convert
     * @return The primitive array instance of the list's contents.
     */
    public static short[] toShortArray(List<Short> list) {
        short[] array = new short[list.size()];
        for (int i = 0; i < list.size(); i++) {
            array[i] = list.get(i);
        }
        return array;
    }

    public static short[] toShortArray(short... arr) {
        return arr;
    }
}

Related

  1. toShortArray(List list)
  2. toShortArray(List values)