0
0

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 1 year has passed since last update.

【Kotlin】リストの要素を結合して1つの文字列に

Last updated at Posted at 2024-01-17

リストの要素を、指定した区切り文字で結合させる方法を以下に記載する。

Kotlinの実装
val freewordList = mutableListOf("a","b","c")
val separator = " "
val freeword = freewordList.joinToString(separator)
println(freeword)
出力結果
a b c

※要素の数が1つの場合でも使用は可能

要素の数が1つの場合
val freewordList = mutableListOf("a")
val separator = " "
val freeword = freewordList.joinToString(separator)
println(freeword)
出力結果
a
0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?