[ [Data(name1, good) ,Data(name2,good)] , [Data(name2,good), Data(name2,bad)] ]
How to convert this List into ArrayList please?
CodePudding user response:
var list = [ [Data(name1, good) ,Data(name2,good)] , [Data(name2,good), Data(name2,bad)] ]
var arraylist = ArrayList(list)
CodePudding user response:
Well first, that is not how to define a list in Kotlin. Since there are no list literals in Kotlin.
Instead, it's like listOf(1, 2, 3, 4,)
for a normal list, and mutableListOf(1, 2, 3, 4,)
for a mutable (editable) list.
MutableList is basically an ArrayList in Kotlin. But there is still arrayListOf()
in Kotlin.
There is also toMutableList()
extension to most Collection
subclasses in Kotlin