Created
August 19, 2019 22:16
-
-
Save donchan922/0b34968f1ff76465d325dbded69720bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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