Java List Remove removeEmpty(List strings)

Here you can find the source of removeEmpty(List strings)

Description

Removes empty strings from the given list

License

Open Source License

Parameter

Parameter Description
strings the list of strings

Return

the new list with no empty values

Declaration

public static List<String> removeEmpty(List<String> strings) 

Method Source Code

//package com.java2s;
/**/*  w  w  w.j a v a2  s. com*/
 * Copyright 2011 Rowan Seymour
 * 
 * This file is part of Imibare.
 *
 * Imibare is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Imibare is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Imibare. If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.ArrayList;
import java.util.List;

public class Main {
    /**
     * Removes empty strings from the given list
     * @param strings the list of strings
     * @return the new list with no empty values
     */
    public static List<String> removeEmpty(List<String> strings) {
        List<String> result = new ArrayList<String>();
        for (String string : strings) {
            if (string.length() > 0)
                result.add(string);
        }
        return result;
    }
}

Related

  1. removeBlankLine(List lines)
  2. removeByRef(List list, Object obj)
  3. removeElement(T element, List list)
  4. removeElementsFromList(List inputList, List elementsToRemove)
  5. removeEmpties(List original)
  6. removeEmptyColumns(List data)
  7. removeEmptyLines(List lines)
  8. removeEmptyLinesFromEnd(List list)
  9. removeEmptyLinesOnSides(List lines)