Java String Function join()

Java String Function join()
Java String Function join()

The java string join() method returns a string joined with given delimiter. In string join method, delimiter is copied for each elements.
In case of null element, “null” is added. The join() method is included in java string since JDK 1.8.
There are two types of join() methods in java string.

Java String join() method example

public class StringJoinExample{  
public static void main(String args[]){  
String joinString1=String.join("-","welcome","to","javatpoint");  
System.out.println(joinString1);  
}}   

Output:

welcome-to-javatpoint
java java string
Recent Posts