Java List Join join(List list, String conjunction)

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

Description

join

License

Open Source License

Declaration

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

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 conjunction) {
        StringBuilder sb = new StringBuilder();

        if (conjunction == null) {
            conjunction = ", ";
        }/* w w w . j  av a2  s.c  om*/

        if (list != null && !list.isEmpty()) {
            for (String string : list) {
                sb.append(string).append(conjunction);
            }

            sb.setLength(sb.length() - conjunction.length());
        }

        return sb.toString();
    }
}

Related

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