Remove long names

Report a typo

There is a Map with countries as keys and capitals as values. You need to implement the method removeLongNames.
It should delete all elements which have a long key or a long value. Long means that their length is bigger than 7 symbols.

Write a program in Java 17
import java.util.*;


class MapFunctions {

public static void removeLongNames(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.removeLongNames(map);

System.out.println(map.size());
}
}
___

Create a free account to access the full topic