import java.util.HashMap; public class HashMapExample { public static void main(String[] args) { HashMapmap = new HashMap<>(); map.put("apple", 1); map.put("banana", 2); map.put("orange", 3); // Print the HashMap before clearing System.out.println("HashMap before clearing: " + map); // Clear the HashMap map.clear(); // Print the HashMap after clearing System.out.println("HashMap after clearing: " + map); } }
HashMap before clearing: {apple=1, banana=2, orange=3} HashMap after clearing: {}
import java.util.HashMap; public class PackageLibraryExample { public static void main(String[] args) { // Check the package of the HashMap class System.out.println("Package of HashMap class: " + HashMap.class.getPackage()); } }
Package of HashMap class: java.util