Java String joining

Introduction

String join() can concatenate two or more strings, separating each string with a delimiter.

static String join(CharSequence delim, CharSequence . . . strs) 

Demonstrate the join() method defined by String.

public class Main {
  public static void main(String args[]) {

    String result = String.join(" ", "HTML", "CSS", "Java");
    System.out.println(result);//  w w  w. j a  va  2 s  . c  om

    result = String.join(", ", "test", "ID:",
                        "E-mail:your@address.here");
    System.out.println(result);
  }
}



PreviousNext

Related