The sameElements() method belongs to the concrete value members of the class iterator of Scala. It checks whether the two stated iterators produce the identical elements in alike order or not. This method won’t terminate for infinite iterators.
- Method Definition:
def sameElements(that: Iterator[_]): Boolean
Where, that is the another iterator stated.
- Return Type:
It returns true if both the iterators produce identical elements in the same order else it returns false.
Here, both the stated iterators are identical so, sameElements method returns true.
Here, both the stated iterators are not identical so, sameElements method returns false.
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.