Java List Join join(String joinString, List strings)

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

Description

join

License

Open Source License

Declaration

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

Method Source Code

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

import java.util.List;

public class Main {
    public static String join(String joinString, List<String> strings) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < strings.size(); ++i) {
            sb.append(strings.get(i));/*from  w  w w .j  av a 2 s  .  c  om*/
            if (i + 1 < strings.size()) {
                sb.append(joinString);
            }
        }
        return sb.toString();
    }

    public static String join(String joinString, String[] strings) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < strings.length; ++i) {
            sb.append(strings[i]);
            if (i + 1 < strings.length) {
                sb.append(joinString);
            }
        }
        return sb.toString();
    }

    public static String join(char joinChar, List<String> strings) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < strings.size(); ++i) {
            sb.append(strings.get(i));
            if (i + 1 < strings.size()) {
                sb.append(joinChar);
            }
        }
        return sb.toString();
    }
}

Related

  1. join(List... ls)
  2. join(List... elements)
  3. join(String _delimiter, List _strings)
  4. join(String delimiter, List strings)
  5. join(String joiner, List joinees)
  6. join(String joint, List elements)
  7. join(String sep, List a)
  8. join(String separator, Collection list)
  9. join(String separator, Collection inputList)