[Java] How to use join method

Programming study diary

October 23, 2020 I used the join method, which is convenient when concatenating strings in Java, so I will summarize it.

What is the join method?

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

[Java] How to use join method
How to use submit method (Java Silver)
[Java] How to use the toString () method
[Java] How to use Map
[Java] How to use Map
How to use java Optional
How to use java class
[Java] How to use Optional ②
[Java] How to use removeAll ()
[Java] How to use string.format
How to use rails join
How to use Java Map
How to use Java variables
[Java] How to use Optional ①
How to use the replace () method (Java Silver)
How to use the link_to method
[Java] How to use compareTo method of Date class
How to use Java HttpClient (Get)
How to use the include? method
How to use the form_with method
How to use Java HttpClient (Post)
[Processing × Java] How to use variables
[Ruby] How to use any? Method
[Java] How to use LinkedHashMap class
[JavaFX] [Java8] How to use GridPane
How to use class methods [Java]
[Java] How to use List [ArrayList]
How to use classes in Java?
[Processing × Java] How to use arrays
How to use Ruby inject method
How to use Java lambda expressions
[Java] How to use Math class
How to use Java enum type
[Java] How to use the File class
[Java] How to use the hasNext function
[Java] How to compare with equals method
[Java] How to use the HashMap class
[Rails] How to use the map method
[Easy-to-understand explanation! ] How to use Java instance
Studying how to use the constructor (java)
[Processing × Java] How to use the loop
How to use Java classes, definitions, import
[Easy-to-understand explanation! ] How to use Java polymorphism
[Java] [Maven3] Summary of how to use Maven3
[Processing × Java] How to use the class
How to use Java Scanner class (Note)
[Processing × Java] How to use the function
[Easy-to-understand explanation! ] How to use ArrayList [Java]
[Java] How to use the Calendar class
[Rails] How to use helper method, confimartion
[Java] Learn how to use Optional correctly
[Easy-to-understand explanation! ] How to use Java overload
try-catch-finally exception handling How to use java
[Easy-to-understand explanation! ] How to use Java encapsulation
How to use Map
How to use rbenv
How to use letter_opener_web
How to use with_option
How to use fields_for
How to use java.util.logging
How to use map