I need to convert a python code into an equivalent java code. Python makes life very easy for the developers by providing lots of shortcut functionalities. But now I need to migrate the same to Java. I was wondering what will the equivalent of dict objects in java? I have tried using HashMap but life is hell. For starters consider this,
# Nodes is a dictionary -> Key : (Name, Strength)
for node, (name, strength) in nodes.items():
nodes[node] = (name, new_strength)
So how to go about converting this into Java? For starters I used HashMap object so,
Map<Integer, List> nodesMap = new HashMap<Integer,List>();
/* For iterating over the map */
Iterator updateNodeStrengthIterator = nodesMap.entrySet().iterator();
while(updateNodeStrengthIterator.hasNext()){ }
My problem is in getting the List part which contains Name & Strength & then updating the Strength part. Is there any feasible way to do this? Should I consider some different data structure? Please help.