Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hashtable elements to vector

 
Meir Yan
Ranch Hand
Posts: 599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hashtable elements to vector

Hello all
I have Hashtable object that contains 3 elements
something like this :

i find it hard to understand why i can't set it right .. i tried to do :
 
Brian Mozhdehi
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.....you want to add the HashTable objects to the Vector or the contents of the HashTable to a Vector?
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what you want is for each element of the Vector to contain a Hashtable with a single element? What are you trying to achieve exactly by dong that?

BTW: Why are you using Vector and Hashtable instead of the more highly recomended ArrayList (or LinkedList) and HashMap
 
Meir Yan
Ranch Hand
Posts: 599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yep single element in the hashtable ( dont ask why .. work )
have to use vector ( also work )
can it be done?
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about :
 
Meir Yan
Ranch Hand
Posts: 599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it seams that Collections.singletonMap makes me some problems
(some iternal application things ) is there aproblem to make
it pure Map(key,value)
so when i debug it will see in the vector elemnts they contain pure hashtables
can it be done ?
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Meir Yan
Ranch Hand
Posts: 599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i dont know why put it fill the vector with empty values , not hashtable
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see what's happening. The put() method returns the value that was just added to the Hashtable. You'll have to instantiate the Hashtable and populate it on separate lines.


[ August 23, 2006: Message edited by: Garrett Rowe ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic