There is a Map with countries as keys and capitals as values. You need to implement the method putThreeCountries.
It should add any three elements to the map.
HashMap
Countries and capitals
Report a typo
Write a program in Java 17
import java.util.*;
class MapFunctions {
public static void putThreeCountries(Map<String, String> map) {
// write your code here
}
}
/* Do not change code below */
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Map<String, String> map = new HashMap<>();
while (scanner.hasNextLine()) {
String s = scanner.nextLine();
String[] pair = s.split(" ");
map.put(pair[0], pair[1]);
}
MapFunctions.putThreeCountries(map);
System.out.println(map.size());
}
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.