Here you can find the source of removeEmpty(List
Parameter | Description |
---|---|
strings | the list of strings |
public static List<String> removeEmpty(List<String> strings)
//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; } }