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 162 views
1 answer 135 views
2 answers 321 views
2 answers 308 views
1 answer 131 views
131 views asked Dec 9, 2024 by avibootz
1 answer 119 views
1 answer 191 views
...