Here you can find the source of combine(final List> r, final char sep)
Parameter | Description |
---|---|
r | the elements list |
sep | the separator |
private static String combine(final List<?> r, final char sep)
//package com.java2s; /******************************************************************************* * Copyright (c) 2015 LegSem.//from w ww . j a va 2 s. c o m * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v2.1 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * * Contributors: * LegSem - initial API and implementation ******************************************************************************/ import java.util.List; public class Main { /** * Combine elements from a list using separator. * * @param r the elements list * @param sep the separator * @return a combined string */ private static String combine(final List<?> r, final char sep) { StringBuilder buf = new StringBuilder(r.get(0).toString()); for (int i = 1; i < r.size(); i++) { buf.append(sep); buf.append(r.get(i)); } return buf.toString(); } }