「Kotlin入門」コレクションのメソッドmutableListOf()を使うサンプル

2020年12月28日

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
fun main(args: Array<String>) {
val mtLstA = mutableListOf(21, 233, 311, 456)
mtLstA.add(234)
val mtLstB = mutableListOf(-21, -233, -311, -456)
mtLstB.add(-234)
println("result1: " + mtLstA)
println("result2: " + mtLstB)
}
fun main(args: Array<String>) { val mtLstA = mutableListOf(21, 233, 311, 456) mtLstA.add(234) val mtLstB = mutableListOf(-21, -233, -311, -456) mtLstB.add(-234) println("result1: " + mtLstA) println("result2: " + mtLstB) }
fun main(args: Array<String>) {
    val mtLstA = mutableListOf(21, 233, 311, 456)
    mtLstA.add(234)

    val mtLstB = mutableListOf(-21, -233, -311, -456)
    mtLstB.add(-234)
 
    println("result1: " + mtLstA)
    println("result2: " + mtLstB)
}

実行結果
>kotlinc sample.kt -include-runtime -d sample.jar
>kotlin sample.jar
result1: [21, 233, 311, 456, 234]
result2: [-21, -233, -311, -456, -234]

Kotlin

Posted by arkgame