Scala Stream head() method with example Improve Improve Like Article Like Save Share Report The head() method is utilized to display the first element of the stream stated. Method Definition: def head: A Return Type: It returns the first element of the stated Stream. Example #1: // Scala program of head() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a Stream val m1 = Stream(3, 6, 7, 4) // Applying head method val result = m1.head // Displays output println(result) } } Output: 3 Example #2: // Scala program of head() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a Stream val m1 = Stream(6, 8, 9, 12) // Applying head method val result = m1.head // Displays output println(result) } } Output: 6 Last Updated : 26 Jul, 2019 Like Article Save Article Previous Scala Queue count() method with example Next Scala List concatenation with example Share your thoughts in the comments Add Your Comment Please Login to comment...