0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Java】joinメソッドの使い方

Posted at

プログラミング勉強日記

2020年10月23日
Javaで文字列を連結するときに便利なjoinメソッドを使ったので、まとめる。

joinメソッドとは

 指定された区切り文字で、文字列を連結するためのメソッド。第一引数を区切り文字(デリミタ)として、第二引数を接頭辞として以降指定された接頭辞の終わりまでの文字列が区切られる。
 デリミタは,(カンマ)、.(ピリオド)、:(コロン)、を指定することができる。

public class Main {
  public static void main(String[] args) throws Exception {
    String str = String.join(",", "apple", "orange", "melon");
    System.out.println(str);
  }
}
実行結果
apple,orange,melon
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?