• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem using pollLastEntry() method from TreeMap  RSS feed

 
Ranch Hand
Posts: 236
5
  • 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()



 
author
Sheriff
Posts: 23513
138
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 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: 236
5
  • 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: 236
5
  • 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
Sheriff
Posts: 23513
138
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 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: 236
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NavigableMap, isn't it? I realised it later and I changed my code
 
Always! Wait. Never. Shut up. Look at this tiny ad.
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!