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 224 views
2 answers 473 views
2 answers 430 views
1 answer 225 views
225 views asked Dec 9, 2024 by avibootz
1 answer 208 views
1 answer 282 views
...