Here you can find the source of appendTo(StringBuilder appendable, Iterable> parts, CharSequence separator)
private static StringBuilder appendTo(StringBuilder appendable, Iterable<?> parts, CharSequence separator)
//package com.java2s; //License from project: Apache License import java.util.Iterator; public class Main { private static StringBuilder appendTo(StringBuilder appendable, Iterable<?> parts, CharSequence separator) { Iterator<?> iterator = parts.iterator(); if (iterator.hasNext()) { appendable.append(toString(iterator.next())); while (iterator.hasNext()) { appendable.append(separator); appendable.append(toString(iterator.next())); }/*from w w w .j a va 2 s . c om*/ } return appendable; } private static CharSequence toString(Object part) { return (part instanceof CharSequence) ? (CharSequence) part : part .toString(); } }