• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

java 6 NavigableMap related Query

 
Ranch Hand
Posts: 71
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have this program as follows



the output of the above is something like this



My Question is related to the behavior of NavigableMap . cause
if you check the output then you will notice that even when i polled first entry of the map it gave me invalid value,but the key was totally correct.
Can anybody puts some knowledge on this and try to explain me as to why this behavior and gave me the second entry value when i polled first entry in this case. And there is a null return in case of a simple get.

Thanks
 
Sheriff
Posts: 28398
100
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Harish Tam wrote:if you check the output then you will notice that even when i polled first entry of the map it gave me invalid value,but the key was totally correct.



I didn't see any invalid value. Could you clarify what you thought was invalid about the output you posted? It all looks perfectly reasonable to me.

(However I suspect you may not completely understand what the pollFirstEntry method does. I recommend you review the API documentation.)
 
Harish Tam
Ranch Hand
Posts: 71
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
check this line of the output



I this this is not valid ,it is One and not Two

Right ?

 
Paul Clapham
Sheriff
Posts: 28398
100
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, I think the output you posted is correct. Can you explain why you expect what you said? After re-reading the API documentation for the method, that is? In particular the first word of the description of the method?
 
Harish Tam
Ranch Hand
Posts: 71
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
do point out if i am wrong in any case

I think the output should be
"navMapSimple pollFirstEntry Value :One "
instead of
"navMapSimple pollFirstEntry Value :Two "

cause the firstEntry is with key : 1
and value :One

i am not sure but this is the case. as per me. If i am wrong please try this code with java 6 compiler

Thanks
 
Paul Clapham
Sheriff
Posts: 28398
100
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What was the first word of the sentence I suggested you should read in the API documentation?
 
Harish Tam
Ranch Hand
Posts: 71
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i got this first part of the line "closest matches for given search targets" from the API docs is it cause of this

it returns the value as Two and not One

so in other case if there is a Question on this output in that case it can be either be One or Two

is there anything else to go with this or just the above part.

please clarify.

Thanks
 
Paul Clapham
Sheriff
Posts: 28398
100
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You obviously haven't even read the description of the pollFirstEntry method, which is this:

The API documentation wrote:Removes and returns a key-value mapping associated with the least key in this map, or null if the map is empty.

 
Harish Tam
Ranch Hand
Posts: 71
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Paul

Looks like i should read the APIs carefully next time :-)

Thanks a bunch
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic