File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Syntax clarification Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Syntax clarification" Watch "Syntax clarification" New topic

Syntax clarification

Ajit Sawant
Ranch Hand

Joined: Nov 26, 2008
Posts: 33
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.

Ruben Soto
Ranch Hand

Joined: Dec 16, 2008
Posts: 1032
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 agree. Here's the link:
subject: Syntax clarification
It's not a secret anymore!