Compile Code

Report a typo

Write the output of the given code:

import java.util.HashMap;

public class SampleCode {
    public static void main(String[] args) {
        HashMap<String, Integer> myMap = new HashMap<>();
        myMap.put("apple", 5);
        myMap.put("banana", 3);
        myMap.put("cherry", 10);
        myMap.put("apple", 7);
        myMap.put("orange", null);
        myMap.remove("apple");
        myMap.getOrDefault("apple", 1);
        System.out.println(myMap.get("apple"));
    }
}
Enter a short text
___

Create a free account to access the full topic