Java List Flatten flatten(List l)

Here you can find the source of flatten(List l)

Description

flatten

License

Apache License

Declaration

public static String flatten(List<String> l) 

Method Source Code

//package com.java2s;
/*//from   w  w  w .jav a2s  . com
 * Copyright 2010 to the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.util.List;

public class Main {
    public static String flatten(List<String> l) {
        StringBuilder sb = new StringBuilder();
        for (String s : l) {
            if (sb.length() > 0)
                sb.append(",");
            sb.append(s);
        }
        return sb.toString();
    }
}

Related

  1. flatten(List> list)
  2. flatten(List input)
  3. flatten(List list, List flat)
  4. flatten(List> nested)
  5. flatten(List>... deeps)
  6. flattenList(List> listOfLists)

  7. HOME | Copyright © www.java2s.com 2016