Scala Iterator seq() method with example
The seq() method belongs to the concrete value members of the class Iterable. It is helpful in visualizing the sequential view of the stated collection. It has a time complexity of O(1).
-
Method Definition:
def seq: Iterator[A]
-
Return Type:
It returns a sequential view of the iterator.
Example :
// Scala program of seq() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Declaring an iterator val iter = Iterator(3, 4, 5, 6, 7) // Applying seq method in // for loop for(n<-iter.seq) { // Displays output println(n) } } } |
chevron_right
filter_none
Output:
3 4 5 6 7
Here, a sequential view of the stated iterator is returned by the seq method of Scala.
Example :
// Scala program of seq() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Declaring an iterator val iter = Iterator(8, 9, 10, 11) // Applying seq method val result = iter.seq // Displays output println(result) } } |
chevron_right
filter_none
Output:
non-empty iterator
Here, a non-empty iterator is returned.
Recommended Posts:
- Scala Iterator take() method with example
- Scala Iterator sum() method with example
- Scala Iterator max() method with example
- Scala Iterator min() method with example
- Scala Iterator zip() method with example
- Scala Iterator map() method with example
- Scala Iterator next() method with example
- Scala Map iterator method with example
- Scala Iterator dropWhile() method with example
- Scala Iterator toIterable() method with example
- Scala Iterator mkString() method with example
- Scala Iterator addString() method with example
- Scala Iterator toBuffer() method with example
- Scala Iterator size() method with example
- Scala Iterator hasNext() method with example
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



