❮ String Methods
Example
String fruits = String.join(" ", "Orange", "Apple", "Mango");
System.out.println(fruits);Definition and Usage
The join() method joins one or more strings with a specified separator.
One of the following
public String join(CharSequence
separator , CharSequence...
elements )public String join(CharSequence
separator , Iterable
elements )Parameter Values
| Parameter | Description |
|---|---|
| separator | Required. The separator used to join the elements |
| elements | Required. Elements to be joined |
Technical Details
| Returns: | A new String , separated by the specified separator |
|---|---|
| Java version: | 1.8 |