Java List Join join(List list, char separator)

Here you can find the source of join(List list, char separator)

Description

join

License

Open Source License

Declaration

public static String join(List list, char separator) 

Method Source Code


//package com.java2s;

import java.util.List;

public class Main {
    public static String join(List list, char separator) {
        if (list == null) {
            return "";
        }/* w w  w .  j ava2  s  .c o  m*/
        int size = list.size();
        if (size == 0) {
            return "";
        }
        if (size == 1) {
            return String.valueOf(list.get(0));
        }
        final StringBuilder sb = new StringBuilder();
        boolean notfirst = false;
        for (Object item : list) {
            if (notfirst) {
                sb.append(separator);
            } else {
                notfirst = true;
            }
            sb.append(item);
        }
        return sb.toString();
    }
}

Related

  1. join(List array, String separator)
  2. join(List elements, String joinWith)
  3. join(List elements, String sep)
  4. join(List items, String separator)
  5. join(List l, String sep)
  6. join(List list, String delim)
  7. join(List list, String delimiter)
  8. join(List list, String flag)
  9. join(List list, String separator)