Java Array Join join(String glue, String[] strings)

Here you can find the source of join(String glue, String[] strings)

Description

join

License

Open Source License

Declaration

public static String join(String glue, String[] strings) 

Method Source Code

//package com.java2s;
/*// www .j  a v  a2  s.  co  m
(C) 2007 Stefan Reich (jazz@drjava.de)
This source file is part of Project Prophecy.
For up-to-date information, see http://www.drjava.de/prophecy
    
This source file is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation, version 2.1.
*/

import java.util.*;
import static java.util.Arrays.asList;

public class Main {
    public static String join(String glue, String[] strings) {
        return join(glue, asList(strings));
    }

    public static String join(String glue, Iterable<String> strings) {
        StringBuffer buf = new StringBuffer();
        Iterator<String> i = strings.iterator();
        if (i.hasNext()) {
            buf.append(i.next());
            while (i.hasNext())
                buf.append(glue).append(i.next());
        }
        return buf.toString();
    }
}

Related

  1. join(String delimiter, Object[] strings)
  2. join(String delimiter, short[] array)
  3. join(String delimiter, String[] array)
  4. join(String delimiter, String[] elements)
  5. join(String delimiter, String[] s)
  6. join(String glue, String[] strings)
  7. join(String s, String[] arr, int off, int end)
  8. join(String s[], String glue)
  9. join(String sep, final String[] strings)