Hey Abhi ,
Are you looking for something like this ?
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class HashMapTest {
public static void main(String[] args) {
HashMap hmap = new HashMap();
hmap.put("A", new Integer(88));
hmap.put("B", new Integer(34));
hmap.put("C", new Integer(53));
hmap.put("D", new Integer(12));
hmap.put("E", new Integer(44));
hmap.put("F", new Integer(56));
hmap.put("Q", new Integer(78));
// below is also valid
hmap.put("R", 60);
Iterator it = hmap.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry) it.next();
int val = (Integer) pairs.getValue();
// print key - values between 55 and 65
if (val >= 55 && val <= 65) {
System.out.println(pairs.getKey() + " = " +
pairs.getValue());
}
}
}
}
Thanks
Tejas
www.tejaspillai.com
On Jan 7, 7:39 am, ABHISHEK TRIPATHI <[email protected]> wrote:
> Hey Dev,
>
> I'm facing probem with the Hashmap, can you please help on this ?
>
> HashMap:
>
> Key= collection of Student Names( A,B,C,D,A,D,Q)
>
> Values= Marks (ex. 88,34,53,12,44,56,78,87,54)
> Can you please advise best way to get all the Students who have marks
> between 55 to 65?
>
> thanks,
> Ami
--
You received this message because you are subscribed to the Google Groups
"JPassion.com: Java Programming" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jpassion_java?hl=en.