• 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

Java Topics Guidance on HashMaps

 
Ranch Hand
Posts: 92
Android
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Question : Why cant we not use or print the value just by index in HashMap  ?
Question 2 : After covering these
1.Java Basic
2.OOP
3.Generics
4.Exception Handling
what should a person learn more about java ? and How much java a man has covered just by knowing these above topics in percentage !!! Please type the topics what should a man learn !
 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Question : Why cant we not use or print the value just by index in HashMap


Maps organise data into keys and values.  HashMap implements Map by using a hash.  A good hash produces a number that broadly scratters the data across its domain.  So there is no index.

Do you want to print the Map values insertion order?

what should a person learn more about java ?


You might benefit from a good Java book at this point, like Effective Java.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when should one use HashMap instead of ArrayList?
 
Knute Snortum
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An ArrayList holds one type of datum and is accessed sequentially (normally).  A Map is accessed by keys.  So if you have a key/value relationship with the data, use a Map.  When the data are to be accessed sequentially, use a List.
 
kunlex jacoby
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Knute Snortum
 
Saloon Keeper
Posts: 10811
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you need to look up values by key then a Map (e.g. HashMap) is the correct tool. If you also need to access the data in the order it was added you can use LinkedHashMap.
 
Marshal
Posts: 79475
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hope I am not too late to welcome you to the Ranch
Have a look in the Java™ Tutorials. I expect that will help you.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic