Countries and capitals

Report a typo

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.

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());
}
}
___

Create a free account to access the full topic