1 | public static String join(String glue, Iterable<String> strings) {
|
2 | StringBuilder buf = new StringBuilder(); |
3 | Iterator<String> i = strings.iterator(); |
4 | if (i.hasNext()) {
|
5 | buf.append(i.next()); |
6 | while (i.hasNext()) |
7 | buf.append(glue).append(i.next()); |
8 | } |
9 | return buf.toString(); |
10 | } |
11 | |
12 | public static String join(String glue, String[] strings) {
|
13 | return join(glue, Arrays.asList(strings)); |
14 | } |
Began life as a copy of #2000504
Snippet is not live.
Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #2000507 |
| Snippet name: | join function + array version |
| Eternal ID of this version: | #2000507/1 |
| Text MD5: | 2cdb43a19ee4a2a133abe754f2721e3a |
| Author: | stefan |
| Category: | |
| Type: | New Tinybrain snippet |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2015-08-09 16:15:10 |
| Source code size: | 445 bytes / 14 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 959 / 1511 |
| Referenced in: | [show references] |