Java Array Join join(String[] sentence, String separator)

Here you can find the source of join(String[] sentence, String separator)

Description

join

License

Apache License

Declaration

public static String join(String[] sentence, String separator) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.List;

public class Main {
    public static String join(String[] sentence, String separator) {
        String result = "";
        for (int i = 0; i < sentence.length; i++) {
            String word = sentence[i];
            result += word + separator;/*from   w ww .ja  v a 2s  .  c o m*/
        }
        return result.trim();
    }

    public static String join(List<String> sentence, String separator) {
        String result = "";
        for (String word : sentence) {
            result += word + separator;
        }
        return result.trim();
    }
}

Related

  1. join(String[] lines, String delim)
  2. join(String[] lines, String sep)
  3. join(String[] lines, String separator)
  4. join(String[] names, String sep)
  5. join(String[] parts, String separator)
  6. join(String[] strArr)
  7. join(String[] strArray, String delimiter)
  8. join(String[] stringArray, boolean quote, String glue)
  9. join(String[] stringArray, String delimiter)