Also consider that for this kind of unordered collections (
Set
s in this case) a particular ordering is not guaranteed (from Set
's documentation: "The iteration order of set elements is unspecified and is subject to change."). Which doesn't mean it's guaranteed that the order is not maintained. Just that the ordering cannot be relied upon.