This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
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

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
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!