Java Array Remove removeEmtpyStrings(String[] strings)

Here you can find the source of removeEmtpyStrings(String[] strings)

Description

Remove all empty/null Strings from the array.

License

Apache License

Declaration

public static String[] removeEmtpyStrings(String[] strings) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;

public class Main {
    /**// w w  w.j  av a 2s.com
     * Remove all empty/null Strings from the array.
     */
    public static String[] removeEmtpyStrings(String[] strings) {
        ArrayList<String> res = new ArrayList<String>();

        for (String string : strings)
            if (!(string == null || string.equals("")))
                res.add(string);

        return res.toArray(new String[res.size()]);
    }
}

Related

  1. removeElement(String[] elements, String element)
  2. removeElement(T[] array, int i)
  3. removeElement(T[] array, T removeObject)
  4. removeElementInStringArray(String[] array, int index)
  5. removeEmpties(String[] array)
  6. removeFirst(String[] args)
  7. removeFirst(String[] array)
  8. removeFirst(String[] in)
  9. removeFirst(String[] strArr)