Java List Join join(List values)

Here you can find the source of join(List values)

Description

join

License

Open Source License

Declaration

public static String join(List<String> values) 

Method Source Code


//package com.java2s;
/*/*from   w w w. java2 s .com*/
 * Copyright (c) 2011 - 2012. Elega9t Ltd. All rights reserved.
 * ELEGA9T PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.Copyright (c) 2011 - 2012. Elega9t Ltd. All rights reserved.
 */

import java.util.List;

public class Main {
    public static String join(List<String> values) {
        return join(values, ", ");
    }

    public static String join(List<String> values, String separator) {
        StringBuilder joined = new StringBuilder();
        for (int i = 0, valuesSize = values.size(); i < valuesSize; i++) {
            String value = values.get(i);
            joined.append(value);
            if (i < values.size() - 1) {
                joined.append(separator);
            }
        }
        return joined.toString();
    }
}

Related

  1. join(List strList, char separator)
  2. join(List strList, String sep)
  3. join(List tokens, String sep)
  4. join(List tokens, String separator)
  5. join(List tokens, String separator)
  6. join(List values, String delimiter)
  7. join(List values, String string)
  8. join(List words, String separator)
  9. join(List entries, String separator)