File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Syntax clarification

 
Ajit Sawant
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


 
Ruben Soto
Ranch Hand
Posts: 1032
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic