Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

24
LINES

< > TinyBrain | #1000810 - join function + array version

JavaX fragment (include)

  public static String join(String glue, Iterable<String> strings) {
    if (strings == null) ret "";
    StringBuilder buf = new StringBuilder();
    Iterator<String> i = strings.iterator();
    if (i.hasNext()) {
      buf.append(i.next());
      while (i.hasNext())
        buf.append(glue).append(i.next());
    }
    return buf.toString();
  }
  
  public static String join(String glue, String[] strings) {
    return join(glue, Arrays.asList(strings));
  }
  
  public static String join(Iterable<String> strings) {
    return join("", strings);
  }
  
  public static String join(String[] strings) {
    return join("", strings);
  }

Author comment

Began life as a copy of #2000507

download  show line numbers  debug dex   

Travelled to 3 computer(s): cfunsshuasjs, ddnzoavkxhuk, onxytkatvevr

No comments. add comment

Snippet ID: #1000810
Snippet name: join function + array version
Eternal ID of this version: #1000810/3
Text MD5: 01e59fea84af87e4acf38539142d8471
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-04-20 18:25:40
Source code size: 665 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 121 / 8880
Version history: 2 change(s)
Referenced in: [show]