| | |
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 |
2dgraphics account android api apple applet application array arrays automation banking binary binarytree bluetooth chat chatprogramusingobjects class classes client code component data database derby design draw eclipse encryption error event exception fractal game givemetehcodez graphics gui html ide if_statement image inheritance input integer interface j2me java javadesktopapplications javaprojects jlabel jni jpanel jtextfield julia linux list loop map method methods midlethttpconnection mobile monitoring netbeans newbie nullpointerexception open-source oracle print printing problem program programming project property recursion reference ria scanner screen search server set size sms sort sourcelabs splash sql static stop string swing testautomation threads time tree ui unicode validation windows






