This week's book giveaway is in the Programmer Certification forum. We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
From the comments int hat code:
//START of anonymous class
That bit in the curly braces is defining an anonymous class that implements the Comparator interface's method.
If you look at the files produced when it's compiled you'll see a <YourClassName>.class file, which is the compiled version of your class, but also a <YourClassName>$1.class, which is the anonymous class.
Ines ilovebears wrote: . . . This is someone's code that I am trying to grasp. . . .
So at least you are not to blame for this:-
. . .
posted 4 years ago
Hi Campbell, Dave, Knute
Thanks for your answers..I am still not clear on the whole topic of anonymous classes and generics but I feel like I am getting some progress. On a scale from 1 to 10 I went
from 0 to 2.. or maybe 1
How about this line:
1) new TreeMap(Comparator<T>) it creates an empty map ->this new map is ORDERED based on the rules I specified in
my Comparator -> then I take my original UNORDERED map and put it into this new map. Correct?
2) on line 56
I am trying to add another entry to my ORDERED map. I get NPE. Why?
I've got no option but to sell you all for scientific experiments. Or a tiny ad: