Join method in Java String
Join method in Java String
The join() method returns a string joined by a delimiter. In the string join method, a delimiter is used for each string being joined. In case string = null, the value “null” is added. The join() method is integrated from JDK 1.8
There are 2 types of join() method.
Method:
public static String join(CharSequence delimiter, CharSequence... elements)
public static String join(CharSequence delimiter, Iterable extends CharSequence> elements)
Example:
public class StringJoinExample {
public static void main(String[] args) {
// TODO Auto-generated method stub
String joinString1 = String.join("-", "welcome", "to", "java");
System.out.println(joinString1);
}
}
Result:

Did you find this article helpful?
Support the author so they can write more quality articles!