How to merge two arrays without duplicate items in Kotlin

1 Answer

0 votes
fun main() {
    val array1 = arrayOf("kotlin", "concise", "android", "app", "kotlin")
	val array2 = arrayOf("phandroidp", "kotlin", "app", "kotlin")

	val mergedArray = (array1 + array2).toSet().toList()

	println(mergedArray)
}


 
/*
run:

[kotlin, concise, android, app, phandroidp]
 
*/

 



answered Dec 9, 2024 by avibootz

Related questions

1 answer 146 views
2 answers 331 views
2 answers 323 views
2 answers 174 views
1 answer 138 views
138 views asked Dec 9, 2024 by avibootz
1 answer 128 views
1 answer 204 views
...