• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Map Conversion

 
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Henry, Thanks a Lot..

My code gets running as I expected it to be..
 
reply
    Bookmark Topic Watch Topic
  • New Topic