This course has already ended.
You cannot submit this assignment

You need to sign in and enrol to submit exercises.

Assignment 6

The indexOf method determines the given element’s location within a collection.

val testVector = Vector("first", "second", "third", "fourth")res11: Vector[String] = Vector(first, second, third, fourth)
testVector.indexOf("second")res12: Int = 1
testVector.indexOf("first")res13: Int = 0
1 point

Experiment with indexOf. Which of the following claims correctly describe how the method behaves in case the given element occurs multiple times in the collection?

1 point

And what does indexOf return if there are no occurences of the given element at all?

4 points

You can also use the parameterless method isEmpty to examine a collection, as well as the contains method, which you can call just like indexOf. Try these methods on some vector or buffer.

Which of the following claims are correct? Select all that apply. Assume that the variable collection refers to some vector or buffer object.

Posting submission...

Earned points

0 / 6

Exercise info

Assignment category
Graded
Your submissions
0 / 5
Deadline
Wednesday, 5 October 2022, 18:00
Late submission deadline
Saturday, 15 April 2023, 12:00 (-100%)
Group size
1-2
Total number of submitters
905