• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Hashtable elements to vector  RSS feed

 
Ranch Hand
Posts: 600
  • 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 :
 
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?
 
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: 600
  • 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: 600
  • 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: 600
  • 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 ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!