Hey,
There are two ways to find the values which are mention below:
Let's take two new sets
scala> var a=Set(1,4,3,4,2)
a: scala.collection.immutable.Set[Int] = Set(1, 4, 3, 2)
scala> var b=Set(7,9,8,2,8)
b: scala.collection.immutable.Set[Int] = Set(7, 9, 8, 2)
You can call &() on one set, and pass another to it.
scala> a.&(b)
res10: scala.collection.immutable.Set[Int] = Set(2)
scala> a.intersect(b)
res11: scala.collection.immutable.Set[Int] = Set(2)
scala> b.intersect(a)
res12: scala.collection.immutable.Set[Int] = Set(2)
If you want to know more about Apache Spark Scala, It's highly recommended to go for the Apache Spark Certification today.