Skip to content

Instantly share code, notes, and snippets.

@donchan922
Created August 19, 2019 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donchan922/0b34968f1ff76465d325dbded69720bf to your computer and use it in GitHub Desktop.
Save donchan922/0b34968f1ff76465d325dbded69720bf to your computer and use it in GitHub Desktop.
StringBuilder stringBuilder = new StringBuilder();
String[] names = {"Alice", "Bob", "Carol"};
String prefix = "";
for (String name : names) {
stringBuilder.append(prefix);
prefix = ",";
stringBuilder.append(name);
}
// Alice,Bob,Carol
System.out.println(stringBuilder.toString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment