• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

How to pass a Map as an object into Hashtable

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in my class i have two hashtables.one hashtable consists of "IP" as a string(key) and "clientInfo"(an object of another class)as a value.
how to do with hashtable.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to do what with a Hashtable? Can you explain what you are trying to do?
 
shivabannuru reddy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the problem is:
one hashtable1( String IP , Object clientInfo)and another hashtable(Interger id, String IP).

if the client passes IP and ClientInfo,then how to add to and retrieve from and remove from hashtable1.

the same operation with the second hashtable.
please give some code.
also how to map these two tables.
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not exactly sure what you are asking. If you need help understanding how to use the HashMap class and other Collections, then you should check out the Collections Trail from Sun's Java Tutorial. This will at least give you a basic understanding of the methods available in different collection classes, including HashMap. Also, if this doesn't help solve your problem directly, then you will have the terminology to help you ask more questions.

HTH

Layne
 
shivabannuru reddy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A singletone class consists of two Hashtables
1. Hashtable1(String IP, Object info)
2. Hashtable2(int id, String IP)

How to add and remove info to first table by using IP
&
How to add and remove IP from second table by using id(this is primitive datatype).

please send some skeleton.
 
author
Posts: 23960
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To add and remove from a hashtable, you can use the put() and remove() methods, respectively. You can check out the documentation in more detail
here.

As for primative, you will have to wrap the int in an Integer object, prior to a put().

Henry
 
Your mind is under my control .... your will is now mine .... read this tiny ad
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic