The way that is evaluated is (TreeSet)(times.headSet(1600))
Here, times.headSet(1600) returns a SortedSet reference to a TreeSet, which means that the whole expression is a legal downcast.
All code in my posts, unless a source is explicitly mentioned, is my own.
I once met a man from Nantucket. He had a tiny ad
a bit of art, as a gift, that will fit in a stocking