-
Notifications
You must be signed in to change notification settings - Fork 23
Collection: Intersection & Union
Devrath edited this page Feb 29, 2024
·
1 revision
code
val numList1 = mutableListOf(
1,2,3
)
val numList2 = mutableListOf(
1,2,3,4
)
fun main(args: Array<String>) {
val result = numList1.union(numList2)
result.forEach {
println(it)
}
println("<---------------->")
val result2 = numList1.intersect(numList2)
result2.forEach {
println(it)
}
}
Output
1
2
3
4
<---------------->
1
2
3