• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

vector can use like hashtable

 
Nilima vyas
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have problem that in place of hashtable i used vector since sequence of my parameter are get disturb since of using hashtable, i used vector so i can mantain the sequence of parameter, but when two parameter have same value using vector , giving list of values for each parameter , i requried the same that each parameter must have only one value.how can i manage thatmy both problem sequence and each key have single value can solve using vector and anybody else.
pls reply me as soon as possible
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Patience, patience.

Have you read the Java Tutorial about collections? Please do.

Both Hashtable and Vector are regarded as less efficient and you usually get better performance with HashMap and ArrayList. If you insist you need a key an a value, you will need a Map. But I don't think you do. Read the descriptions of the interfaces, particularly at the beginning, and see what a Set is, what a List is, and what a Map is.
Do you need to maintain insertion order? Do you need to eliminate duplicates? Do you need to link keys with values? [Have you got a telephone book? That links "keys" to "values" where the name is the "key" and the phone number the "value."]
When you have answers to those questions, you will know what sort of Collection you actually need. Then you can look through the implementations in the tutorial and find which best suits you. There might be combinations; there is, for example, a combination of Links and Hashes and a Set, which might be useful for your purposes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic