When i try to use Collections.addAll method like this:
val articleList1: MutableList<Article> = mutableListOf()
articleList1.addAll(articleList2) // articleList2's type is List<Article> define in java
Compiler complain that ’ type inference failed, please try to specify type arguments explicitly’, which means it use the method public fun <T> kotlin.collections.MutableCollection<in T>.addAll(elements: kotlin.collections.Iterable<T>): kotlin.Boolean
in CollectionsKt.class.
But when i try to specify type for the function:
articleList1.addAll<Article>(articleList2)
Wrong message is ‘No type arguments expected’, which means it use the method public abstract fun addAll(elements: kotlin.collections.Collection<E>): kotlin.Boolean
of MutableList class .
So, what can i do?