File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem using pollLastEntry() method from TreeMap

 
T Vergilio
Ranch Hand
Posts: 142
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Am I doing something stupid? Why am I getting a compilation error:
cannot find symbol method pollLastEntry()


 
Henry Wong
author
Marshal
Pie
Posts: 20836
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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

 
T Vergilio
Ranch Hand
Posts: 142
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
of course!

Thanks a lot, Henry!! Here's me trying to be polymorphic and losing functionality in the process
 
T Vergilio
Ranch Hand
Posts: 142
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 20836
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
T Vergilio
Ranch Hand
Posts: 142
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NavigableMap, isn't it? I realised it later and I changed my code
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic