user3663882
user3663882

Reputation: 7357

Scala equivalent of java.util.Collection?

What is the equivalent of java.util.Collection? I first thought Seq is the way to go, but actually it's an ordered set of elements. I mean we have a numeration of elements.

Upvotes: 1

Views: 1768

Answers (2)

Mike Nakis
Mike Nakis

Reputation: 61959

The picture above is very good looking, but it is not helpful at all in answering the question. (It may be helpful as general reference for other purposes, but not for this purpose.) It is even missing some very important interfaces. So, here is some good old text to try and clear out the confusion:

The Scala equivalent to java.util.Collection is scala.collection.Iterable, despite the mismatch in the name.

You see, scala.collection.Iterable offers the basic functionality of a Java Collection: it has an iterator and a size.

Apparently, what Java calls Iterable Scala calls it Traversable, and then what Java calls Collection Scala calls it Iterable.

Upvotes: 0

Nagarjuna Pamu
Nagarjuna Pamu

Reputation: 14825

Collection Hierarcy

Traversable is on top above iterable

enter image description here

Upvotes: 2

Related Questions