Java HashMap vs Python Dictionary

A Java hashmap is a very popular data structure used to organize data in a way where a unique key can point to a specific value. A Python dictionary could help you achieve the some of the features that a hashmap can provide.

Instantiation

Java

Map<String, String> myMap = new HashMap<String, String>();

Python

my_map = {}

Add Elements

Java

myMap.add("key-1", "value-1");

Python

my_map["key-1"] = "value-1"