What will you add to this code to get map values?
IdentityHashMap
String keys
Report a typo
Sample Input 1:
1
2
3Sample Output 1:
1, 2, 3Write a program in Java 17
import java.util.IdentityHashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Map<String, Integer> map = ... // inititalize an instance of IdentityHashMap
map.put(new String("A"), scanner.nextInt());
map.put(new String("B"), scanner.nextInt());
map.put(new String("C"), scanner.nextInt());
// do not change the code below
System.out.println(
String.join(", ",
map.get("A").toString(),
map.get("B").toString(),
map.get("C").toString())
);
}
}
___
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.