October 23, 2020 I used the join method, which is convenient when concatenating strings in Java, so I will summarize it.
A method for concatenating strings with the specified delimiter. The character string up to the end of the specified prefix is separated by using the first argument as the delimiter and the second argument as the prefix.
The delimiter can specify ,
(comma), .
(period), :
(colon).
Example
public class Main {
public static void main(String[] args) throws Exception {
String str = String.join(",", "apple", "orange", "melon");
System.out.println(str);
}
}
Execution result
apple,orange,melon
Recommended Posts