Here you can find the source of toShorts(Short[] values)
public static short[] toShorts(Short[] values)
//package com.java2s; //License from project: Open Source License public class Main { public static final short DEFAULT_SHORT = 0; public static short[] toShorts(Short[] values) { return toShorts(values, DEFAULT_SHORT); }/* w ww . jav a 2 s . c o m*/ public static short[] toShorts(Short[] values, int defaultValue) { short[] results = new short[0]; if (values != null) { results = new short[values.length]; for (int i = 0; i < results.length; i++) { Short element = values[i]; try { results[i] = (element != null ? element.shortValue() : (short) defaultValue); } catch (Exception ex) { // ex.printStackTrace(); } } } return results; } public static Short[] toShorts(short[] values) { return toShorts(values, DEFAULT_SHORT); } public static Short[] toShorts(short[] values, int defaultValue) { Short[] results = new Short[0]; if (values != null) { results = new Short[values.length]; for (int i = 0; i < results.length; i++) { short element = values[i]; try { results[i] = new Short(element); } catch (Exception ex) { results[i] = (short) defaultValue; // ex.printStackTrace(); } } } return results; } }