Forums Register Login

Syntax clarification

+Pie Number of slices to send: Send
Hello,
Partial code from SCJP 6 pg 586:


I did not understand "subset = (TreeSet)times.headSet(1600)" . What is "(TreeSet)times" trying to do? Please clarify.


+Pie Number of slices to send: Send
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.
I love a woman who dresses in stainless steel ... and carries tiny ads:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 685 times.
Similar Threads
Collections-Getting error, using subList(fromIndex, toIndex) in List!
Generics - Unchecked conversion warning
What is the Use of NavigableMap and NavigableSet?
Subset doubt
ClassCastException using Treemap.headMap()
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 18, 2024 20:36:58.