Hi,
A stream is a lazy list as it evaluates elements only when it needs to. This lazy computation enhances program performance.
scala> val stream=177#::199#::69#::Stream.empty
stream: scala.collection.immutable.Stream[Int] = Stream(177, ?)
Since we don’t need the second element yet, Scala doesn’t evaluate it.
scala> val stream1=(1 to 7).toStream
stream1: scala.collection.immutable.Stream[Int] = Stream(1, ?)
scala> stream.head
Result:
res22: Int = 177
If you want to know more about Apache Spark Scala, It's highly recommended to go for the Spark Course today.