L11.7: Maps Methods Example #2

PHOTO EMBED

Thu Oct 19 2023 01:55:42 GMT+0000 (Coordinated Universal Time)

Saved by @testpro #java

import java.util.HashMap;

public class Main {
    public static void main(String[] args) {

        HashMap<String, String> countryCapitals = new HashMap<>();
        countryCapitals.put("France","Paris");
        countryCapitals.put("Italy", "Rome");
        countryCapitals.put("Norway", "Oslo");
        countryCapitals.put("US", "Washington DC");

        System.out.println( countryCapitals.size());
    }
}
// Output: 4
content_copyCOPY