Implement method log. Print output depending on size: Too many objects if size is greater than 1, Something in the map if size is exactly 1 and There are no objects if map is empty.
The Map interface
How many entries?
Report a typo
Sample Input 1:
3Sample Output 1:
Too many objectsWrite a program in Java 17
import java.util.*;
class Main {
private static void log(Map<Long, String> map) {
// implement me
}
// do not change the code below
public static void main(String[] args) {
String valueBase = "value-";
Scanner scanner = new Scanner(System.in);
Map<Long, String> m = new HashMap<>();
long size = scanner.nextLong();
for (long i = 0; i < size; ++i) {
Long key = i;
String value = valueBase + i;
m.put(key, value);
}
log(Map.copyOf(m));
}
}
___
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.