Java List Join join(List list, String delimiter)

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

Description

join

License

Open Source License

Declaration

public static String join(List<String> list, String delimiter) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.List;

public class Main {
    public static String join(List<String> list, String delimiter) {
        return join(list, delimiter, "");
    }/*  ww w.j  a  va2 s .c o  m*/

    public static String join(List<String> list, String delimiter, String surround) {
        StringBuilder sb = new StringBuilder();
        boolean isFirst = true;
        for (String s : list) {
            if (isFirst) {
                isFirst = false;
            } else {
                sb.append(delimiter);
            }
            sb.append(surround);
            sb.append(s);
            sb.append(surround);
        }
        return sb.toString();
    }
}

Related

  1. join(List list)
  2. join(List list, String conjunction)
  3. join(List list, String delim)
  4. join(List list, String delim)
  5. join(List list, String delimiter)
  6. join(List list, String delimiter)
  7. join(List list, String sep)
  8. join(List list, String separator)
  9. join(List list, String separator)