Don Fredricks

Greenhorn
+ Follow
since Jul 01, 2015
Don likes ...
C++ Java
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
3
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Don Fredricks

Many thanks to Sierra & Bates, and the many helpful posters here at the ranch. I couldn't have done it without y'all.

Don
8 years ago
From http://docs.oracle.com/javase/7/docs/api/java/util/PriorityQueue.html

This class and its iterator implement all of the optional methods of the Collection and Iterator interfaces. The Iterator provided in method iterator() is not guaranteed to traverse the elements of the priority queue in any particular order. If you need ordered traversal, consider using Arrays.sort(pq.toArray()).


Could that be the problem?

Don
One scenario I can envision is that you might, at some time in the future, have a class of employee (SeniorExecutive, perhaps?) for which attendTraining() does not make sense.

That said, other approaches to decomposing the problem space into Java entities are not wrong -- just different.

Don
The Two-Minute Drill at the end of Chapter 6 (page 361) contains the following statement:

"The default block can be located anywhere in the switch block, so if no preceding case matches, the default block will be entered, ..."

I suggest that the word "preceding" is not quite correct; if no other case matches, the default block will be entered.

Ref: http://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html "If no case matches but there is a default label, then all statements after the matching default label in the switch block, if any, are executed in sequence." Note that it says "no case", not "no preceding case".

In years of coding (mostly C/C++), I don't think I've ever seen a default block anywhere but at the end of the switch statement; so the word "preceding" will almost always be correct. But I was worried when I saw this in the book, because I thought it was just the kind of thing the OCA exam might try to use to trip up a hapless candidate.

Don