How to get the first element of List in Scala Last Updated : 19 Nov, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report In Scala, list is defined under scala.collection.immutable package. A list is a collection of same type elements which contains immutable data. Let's see how to get the first element of given List in Scala.List in Scala contains many suitable methods to perform simple operations like head(), tail(), isEmpty(). Coming to list, head() method is used to get the head/top element of the list. below are examples to get first element of list. Example : scala // Scala program to print immutable lists import scala.collection.immutable._ // Creating object object GFG { // Main method def main(args:Array[String]) { // Creating and initializing immutable lists val mylist: List[String] = List("Geeks", "For", "geeks", "is", "a", "fabulous", "portal") println("The head of the list is:") println(mylist.head) } } Output: The head of the list is: Geeks Example : scala // Scala program to creating a uniform list import scala.collection.immutable._ // Creating object object GFG { // Main method def main(args:Array[String]) { // Repeats Scala three times. val myList = List.range(10, 19) println(myList) println("First element is: " + myList.head) } } Output: List(10, 11, 12, 13, 14, 15, 16, 17, 18) First element is: 10 Comment More infoAdvertise with us Next Article How to skip only first element of List in Scala S Shivam_k Follow Improve Article Tags : Scala Scala Similar Reads How to skip only first element of List in Scala In Scala, list is defined under scala.collection.immutable package. A list is a collection of same type elements which contains immutable data. Let's see how to print the element of given List, by skipping the first item in Scala. List in Scala contains many suitable methods to perform simple operat 1 min read Find the last element of a list in scala In Scala, list is defined under scala.collection.immutable package. A list is a collection of same type elements which contains immutable data. we generally use last function to print last element of a list. Below are the examples to find the last element of a given list in Scala. Simply print last 2 min read How to access list elements in Scala? In this articleIn this article, we will learn to access list elements in Scala. List in Scala is the most commonly used collection type, providing an ordered collection that allows accessing elements by index or using functional programming. How to Access List Elements in Scala?Below are the possibl 2 min read How to remove First and Last character from String in Scala? In this article, we will explore different approaches to removing the first and last character from a string in Scala. Table of Content Using substring methodUsing drop and dropRight methodsUsing substring methodIn this approach, we are using the substring method which takes two arguments the starti 1 min read Scala List min() method with example The min() method is utilized to find the smallest element of all the elements in the stated list. Method Definition: def min[B >: A](implicit ord: math.Ordering[B]): A Return Type: It returns the smallest of all the elements in the stated list. Example #1: Scala // Scala program of min() // metho 1 min read How to reverse a list in scala In Scala, list is defined under scala.collection.immutable package. A list is a collection of same type elements which contains immutable data. We use reverse function to reverse a list in Scala. Below are the examples to reverse a list. Reverse a simple list scala // Scala program to reverse a simp 2 min read Like