「Kotlin」StringBuilderのappend()メソッドでint,string,char文字列を結合するサンプル
書式
fun append(value: Char): StringBuilder
fun append(value: String): StringBuilder
fun append(value: Int): StringBuilder
使用例
fun main() { val strA = "study " val strB = "skill in arkgame " val strC =".com" val cft = StringBuilder() cft.append(strA) cft.append(strB) cft.append(strC) println("result1: "+cft.toString()) val strD = 110 cft.append(strD) println("result2: "+cft.toString()) val strE = true cft.append(strE) println("result3: "+cft.toString()) val strF = 'k' cft.append(strF) println("result4: "+cft.toString()) }
実行結果
>kotlinc arkgame.kt -include-runtime -d arkgame.jar
>kotlin arkgame.jar
result1: study skill in arkgame .com
result2: study skill in arkgame .com110
result3: study skill in arkgame .com110true
result4: study skill in arkgame .com110truek