473,394 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

getting values from keys in hashtable

1
i've populated hashtable ht as

ht.put(i,string) -- i is an object of integer class.

i want to retrieve the corrseponding string data using the key.
can anyone help me.
Aug 26 '07 #1
1 1914
JosAH
11,448 Expert 8TB
i've populated hashtable ht as

ht.put(i,string) -- i is an object of integer class.

i want to retrieve the corrseponding string data using the key.
can anyone help me.
If you're using Java 1.5 or later you can use autoboxing:

Expand|Select|Wrap|Line Numbers
  1. int key= 42;
  2. String value= ht.get(key);
  3.  
If you're still using Java 1.4 or earlier, you have to do something like this:

Expand|Select|Wrap|Line Numbers
  1. Integer key= new Integer(42);
  2. String value= ht.get(key);
  3.  
kind regards,

Jos
Aug 26 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: John Meredith via .NET 247 | last post by:
Hi all, I used all your info to come up with the following conclusion when I needed to modify my Hashtable object. 1) Create an ArrayList from the Hashtable keys so that we have something to...
4
by: bpdace | last post by:
I have a datasource that is being passed in as a Hashtable. I want to load in all the Values (strings inside the Value, not the Keys) into a collumn inside a DataTable. The values need to be sorted...
1
by: Marc Scheuner [MVP ADSI] | last post by:
Folks, I'm struggling with XSLT key's and stuff.... anybody out there who *REALLY* understands this stuff??? Okay, my XML file looks something like this (partially): <?xml version="1.0"...
3
by: M | last post by:
I am trying to copy the values of one hashtable to another. I ran into a read only error when using the IDictionaryEnumerator. while (myHashEnumerator.MoveNext()){ while...
4
by: Vladimir C. | last post by:
Hashtable map = new Hashtable(); map = 10; map = 20; foreach(DictionaryEntry e in map) { e.Value = 100; Console.WriteLine("{0}: {1}", key, map); }
8
by: SenthilVel | last post by:
how to get the corresponding values for a given Key in hashtable ??
5
by: ad | last post by:
I have a hashtable name myHash. sKey is a string, I use myHash to retrieve the value of that key. But is sKey is not in the myHash.Keys, it raise an Exception. I want to dertiminate if sKey in...
4
by: Neil Wallace | last post by:
Hi there, I have an application in which a grid of 100 or more buttons are put on a form in columns of 10. All the buttons are within a panel. They are added in runtime, and so they adopt a...
2
by: andrewcw | last post by:
I have a reason to resuse hashtables and I'd like to set the values to null without having to reload the keys.- > which is what the clear method does. If I try a foreach construct I get an error...
12
by: =?Utf-8?B?SnVsaWEgQg==?= | last post by:
Hi all I'm creating a hashtable of a list of users in AD. The keys are UserID and Password. I want to loop through the table to compare the userID and password with values that a user has...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.