aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Problem using pollLastEntry() method from TreeMap Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Problem using pollLastEntry() method from TreeMap" Watch "Problem using pollLastEntry() method from TreeMap" New topic
Author

Problem using pollLastEntry() method from TreeMap

Chandella Montero
Ranch Hand

Joined: Feb 18, 2011
Posts: 89
Am I doing something stupid? Why am I getting a compilation error:
cannot find symbol method pollLastEntry()




OCA, OCP Java 6
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19072
    
  40


Hint: What is the type of the myMap variable? ... not the instance itself, but the type of the reference?


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Chandella Montero
Ranch Hand

Joined: Feb 18, 2011
Posts: 89
of course!

Thanks a lot, Henry!! Here's me trying to be polymorphic and losing functionality in the process
Chandella Montero
Ranch Hand

Joined: Feb 18, 2011
Posts: 89
And to think I spent ages looking at it without being able to see the problem...

Here is the amended code, using the NavigableMap interface instead:



the result...

Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19072
    
  40

Chandella Montero wrote:of course!

Thanks a lot, Henry!! Here's me trying to be polymorphic and losing functionality in the process


BTW, there is actually an interface, that is supported by the TreeMap class, that includes the method that you want.

Henry
Chandella Montero
Ranch Hand

Joined: Feb 18, 2011
Posts: 89
NavigableMap, isn't it? I realised it later and I changed my code
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem using pollLastEntry() method from TreeMap