Код: Выделить всё
js>["Bill","Bob","Steve"].join(" and ")
Bill and Bob and Steve
Код: Выделить всё
static public String join(List list, String conjunction)
{
StringBuilder sb = new StringBuilder();
boolean first = true;
for (String item : list)
{
if (first)
first = false;
else
sb.append(conjunction);
sb.append(item);
}
return sb.toString();
}
Подробнее здесь: https://stackoverflow.com/questions/175 ... ind-string
Мобильная версия