• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

core java

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when we r using Vector and HashMap in real time
?
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This forum (JavaRanch) is for Questions, suggestions and whining about this site. Use the other forums to ask questions about Java.

I'm moving this thread to Java in General - beginner.
 
Sainath Veepuri
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
It's a fact that Vector and HashMap fall under the collections frame work in java.
HashMap would be useful when we would like to keep a track over the objects which are being added to it.HashMap follows a key-value pair combination.HashMap is not thread safe (not synchronized). Hence the performance should be faster.

Vector is heavily synchronized, hence this should be slower, but then it's thread safe.

In context to the vector and hashmap, unless I need a key-value pair combination and performance to be faster, I would use a HashMap.
Else I would use a Vector if I'am not worried about performance, but to have it thread safe.
Hope this should give you some idea..
Thanks,
Sai.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic