how to use me.getKey(); as an integer , (plz Read)
in
Programming Questions
•
1 month ago
hi can somebody help me with this problem i need to be able to do the follow exemple:
-------------------------------------------------------------------------
import java.util.Map;
HashMap<Integer,Integer> hm = new HashMap<Integer,Integer>();
hm.put(1, 1); hm.put(2, 35); hm.put(3, 36); ~int a ;
for (Map.Entry me : hm.entrySet()) {
print(me.getKey() + " is ");
println(me.getValue());
a = me.getKey();
//the red part is wrong because the compiler says that me.getKey(); is a object and not an integer
// but when u do print(me.getKey()) ,it will be printed s an integer
}
-------------------------------------------------------------
note: BLUE = CORRECT; RED = INCORRECT;
can somebody plz help me with this problem?sorry for the english
:D ty
------------------------------------------------------------------------
-------------------------------------------------------------------------
import java.util.Map;
HashMap<Integer,Integer> hm = new HashMap<Integer,Integer>();
hm.put(1, 1); hm.put(2, 35); hm.put(3, 36); ~int a ;
for (Map.Entry me : hm.entrySet()) {
print(me.getKey() + " is ");
println(me.getValue());
a = me.getKey();
//the red part is wrong because the compiler says that me.getKey(); is a object and not an integer
// but when u do print(me.getKey()) ,it will be printed s an integer
}
-------------------------------------------------------------
note: BLUE = CORRECT; RED = INCORRECT;
can somebody plz help me with this problem?sorry for the english
:D ty
------------------------------------------------------------------------
1