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 219 views
2 answers 468 views
2 answers 426 views
1 answer 220 views
220 views asked Dec 9, 2024 by avibootz
1 answer 203 views
1 answer 278 views
...