object Scala_List
{
def main(args: Array[String]): Unit =
{
val colors = List("Red", "Blue", " Black ", "Green", " White", "Pink")
println("Original list:")
println(colors)
println("First element of the said list: " + colors.head)
println("Last element of the said list: " + colors.last)
}
}
Sample Output:
Original list:
List(Red, Blue, Black , Green, White, Pink)
First element of the said list: Red
Last element of the said list: Pink
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer