473,664 Members | 3,001 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getting key coresponding to value in hashtable

9 New Member
Hi

can i get key corresponding to a particular value in hashtable in java.

we can get value corresponding to particular key but if we want to get key corresponding to particular value.........
Do write code
How?

Thanks'
Atul
Aug 3 '07 #1
1 1976
JosAH
11,448 Recognized Expert MVP
Hi

can i get key corresponding to a particular value in hashtable in java.

we can get value corresponding to particular key but if we want to get key corresponding to particular value.........
You need another Map for that but beware that different keys in the first map
may have identical values in the second map, so if the first map has type:

Expand|Select|Wrap|Line Numbers
  1. Map<K, V>
  2.  
then the second Map needs to have a type:

Expand|Select|Wrap|Line Numbers
  1. Map<V, List<K>>
  2.  
or similar.

Do write code
How?
I do write a lot of code; do you?

kind regards,

Jos
Aug 3 '07 #2

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

Similar topics

3
11865
by: suresh | last post by:
Hi all, I have a hash table and I want to modify the value of a key. Please let me know how can that be acheived. Thanks Suresh
4
17477
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); }
1
3106
by: Pavils Jurjans | last post by:
Hello, I am building custom hashtable class, and thinking about value retrieval issues. The thing is, that sometimes the hashtable value may contain value null. If someone is reading this value like this value = myHashtable; then, is the value of "myKey" key is null, then the result is the same, as
8
59511
by: SenthilVel | last post by:
how to get the corresponding values for a given Key in hashtable ??
7
20115
by: Dan | last post by:
I have the need to translate values back and forth. I have created a Hashtable to do this because I don't care about intrinsic order and I want it to be a fast as possible. My only concern is that I doubled the size of my Hashtable to accommodate translating both ways. Kind of like the following, but longer with more complicated data. Hashtable ht = new Hashtable(); ht.Add("x1", "y1"); ht.Add("x2", "y2"); ht.Add("y1", "x1");
7
36802
by: ad | last post by:
I have a hash table like: Hashtable myHT = new Hashtable(); myHT.Add("First", "Hello"); myHT.Add("Second", "World"); myHT.Add("Third", "!"); We can use key to find value like: myHT -> "Hello" But how can use use value to find key?
11
1949
by: The Crow | last post by:
i have a arraylist. say it contains integer values. i want to be able to inform user, which indexes in the array contain same values. but there can be N different values, and M different indexes having the same value. actually i will do this with javascript array to inform user which input's have same value. but i think its not a matter.
2
1370
by: Michael | last post by:
Hi All, I have something going wrong with the XmlTextReader. I have a function that reads the following XML example. For some reason the code is only getting two of the 3 Values elements. Here is some code I'm using: Thanks for any suggestions. <?xml version="1.0" encoding="windows-1252" ?> <MMTP> <LookUp> <ControlType>C1ComboBoxList</ControlType>
3
1537
by: Rich | last post by:
Hello, I populate a hashtable with recordID's in a "For i=0 to n" loop. Some recordID's are duplicate but for different rows (recordID is not a key field in this scenario). I use the value of "i" in the For loop as the key in the hashtable (which is actually the currencyManager counter). Originally, I was using the recordID as the key and "i" as the value. So if I user needed to go to recordID = 12345, I just retrieve the...
0
8437
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8348
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8861
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8778
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7375
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4185
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4351
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2003
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1759
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.