Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Join Strings in Java
To join strings in Java, use the String.join() method. The delimiter set as the first parameter in the method is copied for each element.
Let’s say we want to join the strings “Demo” and “Text”. With that, we want to set a delimeter $. For that, use the join() method as shown below −
String.join("$","Demo","Text");
The following is an example.
Example
public class Demo {
public static void main(String[] args) {
String str = String.join("$","Demo","Text");
System.out.println("Joined strings: "+str);
}
}
Output
Joined strings: Demo$Text
Advertisements
