Set is divided into mutable Set and immutable Set.

Set

Set1 = set1.+(4) println(set2) // Set(1, 2, 2, 3) println(1, 2, 3) 2, 3, 4) val set3 = set1 + 4 println(set3) // Set(1, 2, 3, 4) // Set(1, 2, 3, 4) println(2, 3, 4) // // Set(1, 1, 2, 3, 3, 4, 5) Set(2, 3, 4, 5) Set(2, 3, 4, 5) Set(2, 3, 4, 5) // set6. Foreach (println) // Set(1, 2, 3) union (Set(2, 3, 4)) println(set7) // Set(1, 2, 3, 3) Println (set8) // Set(1, 2, 1) // intersection val set9 = Set(1, 2, 2) diff (Set(2, 3, 4)) 3) intersect (Set(2, 3, 4)) println(set9) // Set(2, 3)

mutable.Set

Cycling, union, difference and handover are also mentioned above, which will not be described here

Println (set1) // Set(1, 2, 3) // Set(1, 2, 3) // Set(1, 2, 3) Set1. Add (5) println(set1) // Set(1, 2, 3, 4) // Set(1, 2, 3, 4) Set(1, 2, 6) println(1) println(2, 3, 4) // set1 ++= mutable.Set(1, 2, 6) println(1, 5, 2, 6) // set1 ++= mutable. 3, 4)