Android examples for java.lang:array element remove
remove Nulls from string array
import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.text.TextUtils; import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; public class Main{ @NonNull/*from ww w . j av a 2s . com*/ public static String[] removeNulls(@NonNull String[] args) { List<String> list = new ArrayList<>(Arrays.asList(args)); list.removeAll(Collections.singleton(null)); return list.toArray(new String[list.size()]); } }