object Scala_List
{
def main(args: Array[String]): Unit =
{
val nums = List(1, 3, 5, 2, 7, 9, 11, 5, 2, 14, 12, 3)
println("Original list:")
println(nums)
val result = nums.isEmpty
println("Test the said list is empty or not?")
println(result)
val nums1 = List()
val result1 = nums1.isEmpty
println("Test the said list is empty or not?")
println(result1)
}
}
Sample Output:
Original list:
List(1, 3, 5, 2, 7, 9, 11, 5, 2, 14, 12, 3)
Test the said list is empty or not?
false
Test the said list is empty or not?
true
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer