Here you can find the source of removeEmptyElements(String[] firstArray)
Parameter | Description |
---|---|
allElements | a parameter |
public static String[] removeEmptyElements(String[] firstArray)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; public class Main { /**//w w w . ja v a 2 s . c o m * Removes empty (or null) element from a given string array and returns a copy without thouse elements * * @param allElements * @return */ public static String[] removeEmptyElements(String[] firstArray) { List<String> stringList = new ArrayList<String>(); for (String string : firstArray) { if (string != null && string.trim().length() > 0) { stringList.add(string); } } firstArray = stringList.toArray(new String[stringList.size()]); return firstArray; } }