Manning's Countdown to 2014
. Use discount code crdotd14 all month for 50% off every deal.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Programmer Certification (SCJP/OCPJP)
Joined: Nov 26, 2008
Jan 07, 2009 20:44:54
Partial code from
6 pg 586:
... TreeSet<Integer> times = new TreeSet<Interger>(); times.add(1205); times.add(1545); TreeSet<Integer> subset = new TreeSet<Interger>(); subset = (TreeSet)times.headSet(1600); System.out.println("J5 - last bwfore 4 pm is : " + subset.last()):
I did not understand "subset = (
)times.headSet(1600)" . What is "(
)times" trying to do? Please clarify.
Joined: Dec 16, 2008
Jan 07, 2009 20:56:41
The way that is evaluated is (
Here, times.headSet(1600) returns a
reference to a
, 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
ClassCastException using Treemap.headMap()
What is the Use of NavigableMap and NavigableSet?
Collections-Getting error, using subList(fromIndex, toIndex) in List!
Generics - Unchecked conversion warning
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013