| | |
hashmap
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
HashMap
or
Java Syntax (Toggle Plain Text)
HashMap map = new HashMap(); map.put("ONE",new Integer(1)); Integer integ = (Integer)map.get("ONE"); int value = integ.intValue();
or
Java Syntax (Toggle Plain Text)
HashMap map = new HashMap<String,Integer>(); map.put("ONE",1); int integ = (Integer)map.get("ONE");
Last edited by javaAddict; Oct 13th, 2008 at 2:18 pm.
Check out my New Bike at my Public Profile at the "About Me" tab
I think you may have meant Missing type on declaration and redundant cast on map.get().
Java Syntax (Toggle Plain Text)
Map<String, Integer> map = new HashMap<String, Integer>(); map.put("ONE", 1); int value = map.get("ONE");
thank you for replies so soon. its making more sense for me now, but still there is some confusion, what i have is like this
private Map<Object, String> map= new HashMap <Object, String>();
and i need to create new int variable and use that to keep track of the that hashmap. so if u guys just explain me some more. thanks you.
private Map<Object, String> map= new HashMap <Object, String>();
and i need to create new int variable and use that to keep track of the that hashmap. so if u guys just explain me some more. thanks you.
Best
Codered152
Codered152
•
•
•
•
thank you for replies so soon. its making more sense for me now, but still there is some confusion, what i have is like this
private Map<Object, String> map= new HashMap <Object, String>();
and i need to create new int variable and use that to keep track of the that hashmap. so if u guys just explain me some more. thanks you.
in other words can i do something like this.
int intVariable = map;
so all the hashmap value store in intVariable.
Best
Codered152
Codered152
•
•
Join Date: Apr 2007
Posts: 126
Reputation:
Solved Threads: 6
Here's what you can do:
java Syntax (Toggle Plain Text)
HashMap map = new HashMap(); map.put(new Integer(1), new String("ONE")); map.put(new Integer(2), new String("TWO")); map.put(new Integer(3), new String("THREE")); int one = Integer.parseInt(map.get(new Integer(1)).toString()); and so on...
![]() |
Similar Threads
- Ordered String from a HashMap (Java)
- Ordering HashMap values (Java)
- How to implement a binary tree Using HashMap Collection in java (Java)
- HashMap, Iterating problem (Java)
- How to use collection in java (Java)
- making a string .. name of an object (Java)
Other Threads in the Java Forum
- Previous Thread: help with reaction on this...
- Next Thread: Problem reading an infile
| Thread Tools | Search this Thread |
3d @param affinetransform android api applet application arc arguments array arrays automation binary bluetooth byte capture chat class classes click client code color compare component count database design detection eclipse eclipsedevelopment encryption error event exception fractal game givemetehcodez graphics gridlayout gui guitesting helpwithhomework html ide if_statement image input integer interface j2me java java.xls javaprojects jni jpanel julia keytool keyword linux list loop macintosh map method methods mobile netbeans newbie object os pong print problem producer program programming project projectideas read recursion replaysolutions rim scanner screen server set size sms sort sql string swing terminal threads transforms tree ui web windows






