Campbell Ritchie wrote:I think it is unfortunate that the same word “cast” is used for both.
"I have some object here, and I want you to treat it as if it of type X"
But does the inclusive parameter add so much to the method signature as to require a type difference in the return? Why not just make the return type a SortedSet as well?
As I recall, most Sets are simply a container to a Map<K, Boolean>
In this case it would actually work, but that's because TreeSet is itself only a wrapper for a NavigableMap (by default a TreeMap)
indeed, if you don't need to use it after that, you can simply make the last line:
Set<Integer> smallSet = times.headSet(100);
time.headSet() method returns a SortedSet<Integer>, not a TreeSet<Integer>
not all SortedSet<Integer>s are TreeSet<Integer>s
thank you paul it helped a lot.
for(shoppingCartItem scItem:items)...
Two different objects, two different locks, so no mutual exclusion.
No, as long as both methods are static or both are non-static.
That sounds kind of bossy. Comments like that run the risk of alienating the people whose help you seek.