我有此链接中所述的相同问题(但很快) Getting common data from two different types of array
我尝试过:
val list=ArrayList<Model>()
val list1=ArrayList<Model1>()
val hashMap=Hashmap<Int,Int>()
for (i in list.indices) {
val data = list1.filter { it.name == list[i].name }
if (data.isnotEmpty()) {
hashMap.put(data[0].id,list[i].id)
}
}