Java tutorial
//package com.java2s; import java.lang.reflect.Array; import java.util.ArrayList; public class Main { public static <T> T[] asArrayRemoveNulls(Class<T> a_class, T[] values) /* */ { /* 509 */ArrayList valueList = new ArrayList(values.length); /* 510 */for (Object t : values) /* */ { /* 512 */if (t == null) /* */continue; /* 514 */valueList.add(t); /* */} /* */ /* 517 */return (T[]) valueList.toArray((Object[]) (Object[]) Array.newInstance(a_class, valueList.size())); /* */} }