Java List to Short Number Array toShortArray(List list)

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

Description

to Short Array

License

Open Source License

Declaration

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

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.*;

public class Main {
    public static short[] toShortArray(List<Short> list) {
        if (isNullOrEmpty(list)) {
            return null;
        }//  www  .j a v  a  2s  .  c om
        short[] shorts = new short[list.size()];
        for (int i = 0; i < shorts.length; i++) {
            shorts[i] = list.get(i);
        }
        return shorts;
    }

    public static boolean isNullOrEmpty(Collection c) {
        return c == null || c.isEmpty();
    }

    public static boolean isNullOrEmpty(String s) {
        return s == null || s.isEmpty();
    }
}

Related

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