I'm trying to access to the values of a pair from a hashmap. I have got a Map where Integer is the key and info is the value. I want to iterate through the map and get the specific data field (namePlayer) from the info object.
class info{
public String namePlayer;
public String knowledge;
public int coins;
info(String nom,String coneixament,int monedes){
namePlayer=nom;
knowledge=coneixament;
coins=monedes;
}
void setMonedes(int monedes){
coins=monedes;
}
void setConeixement(String confianza){
knowledge=confianza;
}
String getConeixament(){
return knowledge;
}
String getNames(){
return name;
}
}
public class Memory{
private Map<Integer,info> k;
Memory(){
k= new HashMap<Integer, info>();
}
void getValues(){
Iterator it = _infoPartida.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pair = (Map.Entry)it.next();
info s = pair.getValues();// error
String name = s.getNames():
}
}
}