• Post Reply Bookmark Topic Watch Topic
  • New Topic

Map Conversion  RSS feed

 
Mark Reyes
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

I'm having this problem on data type conversion between a map and a string array and outputting the result.



What I expect for the output is the manner at which I add it to the map.
My expected output was "one", "two","three","four"..."eight" and this is the sequential way on how I add the object to the map.

But when i ran the code, the output gets jammed "eight", "five","four","one"...."two".

By the way, I did some test and change the collection type from a Map to an ArrayList. I then perform String array conversion, and the output was the manner how I add it to the arraylist. But I dont need an arraylist but a map. I'm wondering whats the difference between a map and arraylist conversion to string array?

Is there a way for me to have my output be synchronized in the manner I inserted it my collection(map)? I'm running in circles thinking of possible ways on how to execute this. Need some advice. Thanks to all ranchers..
 
Henry Wong
author
Sheriff
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way for me to have my output be synchronized in the manner I inserted it my collection(map)? I'm running in circles thinking of possible ways on how to execute this. Need some advice. Thanks to all ranchers..


Take a look at the java.util.LinkedHashMap.

Henry
 
Mark Reyes
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Henry, Thanks a Lot..

My code gets running as I expected it to be..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!