If I have a Hashmap as follows:
Hashmap<String, Node> nodeMap = new HashMap<String, Node>();
and Node stores multiple values consists of:
String name,
int year,
double weight
How can I print out one of the multiple values stored in this hashmap? I actually have no idea to just print one of the value (which is what I need the most) But as a start, I tried to print all the values first by using following query
Set<String> keySet= nodeMap.keySet();
for(String x:keySet){
System.out.println(nodeMap.get(x));
}
However, I got an output for example like Node@73a28541, Node@6f75e721, Node@69222c14.
I am trying to get the real value of like what is the name, what year, and what is the weight of each key in the Hashmap but it is still not working yet.
And I actually need to know how to print just one of the value..
Any help would be really appreciated. Thank you
EDIT: This is how I stored the Hashmap and node value:
Node n = new Node(resultSet.getString(1), resultSet.getInt(2),weight);
nodeMap.put(resultSet.getString(1),n);
My expected output is that if I have a certain key for example 123, I want to get the year value of the 123 key.