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

2 answers 158 views
1 answer 133 views
2 answers 315 views
2 answers 301 views
1 answer 126 views
126 views asked Dec 9, 2024 by avibootz
1 answer 118 views
1 answer 188 views
...