Java List Join join(List strings, String separator)

Here you can find the source of join(List strings, String separator)

Description

join

License

Apache License

Declaration

public static String join(List<String> strings, String separator) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.List;

public class Main {
    public static String join(List<String> strings, String separator) {
        if (strings == null || strings.isEmpty()) {
            return "";
        }//from   w w w.  jav  a 2  s .  c  om

        StringBuilder b = new StringBuilder();
        for (int i = 0;; i++) {
            b.append(strings.get(i));
            if (i == strings.size() - 1) {
                return b.toString();
            }
            b.append(separator);
        }
    }
}

Related

  1. join(List strings, String delimiter)
  2. join(List strings, String join)
  3. join(List strings, String joiner)
  4. join(List strings, String sep)
  5. join(List strings, String separator)
  6. join(List strings, String separator)
  7. join(List strings, String separator)
  8. join(List strings, String separator)
  9. join(List stringsToJoin, char delimiter)