我有一个数据类,它有列表形式的数据(伴随对象).我根据自己的要求将这些列表分配给活动类中的变量(列表).
我的密码
class DataLists {
companion object {
val CountryList: List<CountryDataStructure> = listOf(
CountryDataStructure(1, "USA"),
CountryDataStructure(2, "Canada"))
}
}
活动课
var CountryData = DataLists.CountryList
CountryData[0].Name = "United States of America"
//Here the Companion object list (CountryList) i.e. DataList is also changed and have
//values "United States of America" and "Canada" while I expect this to have "USA" and "Canada"