Java List Join join(List list)

Here you can find the source of join(List list)

Description

join

License

Open Source License

Declaration

public static String join(List<String> list) 

Method Source Code

//package com.java2s;
//License from project: GNU General Public License 

import java.util.Iterator;
import java.util.List;

public class Main {
    public static String join(List<String> list) {
        return join(list, " ");
    }/*from w  ww  . ja  v  a2s.  c  o m*/

    public static String join(List<String> list, String separator) {
        Iterator<String> iter = list.iterator();
        String result = iter.hasNext() ? iter.next().toString() : "";
        while (iter.hasNext())
            result += separator + iter.next();
        return result;
    }

    public static String join(String[] list, String separator) {
        String result = list.length > 0 ? list[0] : "";
        for (int i = 1; i < list.length; i++)
            result += separator + list[i];
        return result;
    }
}

Related

  1. join(List lines, char delim)
  2. join(List list)
  3. join(List list)
  4. join(List list)
  5. join(List list)
  6. join(List list)
  7. join(List list, String conjunction)
  8. join(List list, String delim)
  9. join(List list, String delim)