The map() method is utilized to apply the stated function to all the elements of the list.
Method Definition: def map[B](f: (A) => B): List[B]
Return Type: It returns a new list after applying the stated function to all the elements of the list.
List(6, 9, 15, 21, 24)
List(4, 9, 25, 49, 64)
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.