Java String Join join(String... xs)

Here you can find the source of join(String... xs)

Description

join

License

Open Source License

Declaration

public static String join(String... xs) 

Method Source Code


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

import java.util.List;

public class Main {
    public static String join(String... xs) {
        StringBuilder sb = new StringBuilder();
        for (String x : xs)
            sb.append(x);/*from ww w .j  a v  a2s .c om*/
        return sb.toString();
    }

    public static String join(List<String> xs) {
        StringBuilder sb = new StringBuilder();
        for (String x : xs)
            sb.append(x);
        return sb.toString();
    }

    public static String join(List<String> xs, String sep) {
        int sepLen = sep.length();
        StringBuilder sb = new StringBuilder();
        for (String x : xs)
            sb.append(x).append(sep);
        return sb.length() > 0 ? sb.delete(sb.length() - sepLen, sb.length()).toString() : "";
    }
}

Related

  1. join(String separator, String... strings)
  2. join(String separator, String... strings)
  3. join(String splitter, String... strs)
  4. join(String str[], String splitter)
  5. join(String... paths)
  6. join(T delimiter, List list)
  7. join2(String connector, String... strs)
  8. joinColumns(Iterable columns)
  9. joinedList(T first, T... others)