[ [Data(name1, good) ,Data(name2,good)] , [Data(name2,good), Data(name2,bad)] ]
How to convert this List into ArrayList please?
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
convert List to ArrayList in Kotlin
fun getAllHome(){
var list : List<HomeEntity> = ArrayList()
var myArrayList= list.listToArrayList()
}
companion object {
fun <T> List<T>.listToArrayList(): ArrayList<T> {
val array: ArrayList<T> = ArrayList()
for (index in this) array.add(index)
return array
}
}