Question | Click to View Answer |
What does the following code print? val leaders = collection.mutable.Buffer("Reykon")
leaders += "obama"
println(leaders)
|
|
What does the following code print? val stuff = collection.mutable.Buffer("blue")
stuff += 44
println(stuff)
|
This code throws an error. Strings are the only item that can be appended to the You cannot append an integer to a buffer with the |
What does the following code print? val coolCreatures = collection.mutable.Buffer()
coolCreatures += "spongebob"
println(coolCreatures)
|
This code throws an error. val coolCreatures = collection.mutable.Buffer[String]()
coolCreatures += "spongebob"
println(coolCreatures)
|
What does the following code print? val turtles = collection.mutable.Buffer("mikey", "leo")
turtles(0) = "donny"
println(turtles)
|
The buffer is initially defined with mikey as the first element and leo as the second element. |
What does the following code print? val fruits = collection.mutable.Buffer("apple", "orange")
println(fruits.toList)
|
The |
What does the following code print? val veggies = collection.mutable.Buffer("carrots")
veggies += "peas"
println(veggies.last)
|
The |