10.4 Map Interface (HashMap Internal Working)
10.4 Map Interface (HashMap Internal Working)
import java.util.HashMap;
import java.util.Map;
public class MapDemo {
public static void main(String[] args) {
Map<String, Double> stockPrices = new HashMap<>();
stockPrices.put("TCS", 3850.50);
stockPrices.put("INFY", 1520.00);
stockPrices.put("RELIANCE", 2950.75);
System.out.println("TCS Price: ₹" + stockPrices.get("TCS"));
for (Map.Entry<String, Double> entry : stockPrices.entrySet()) {
System.out.println(entry.getKey() + " -> ₹" + entry.getValue());
}
}
}🧭 Navigation
- ⬅️ पिछला चैप्टर: 10.3 Set Interface (HashSet vs TreeSet)
- अगला चैप्टर ➡️: 10.5 Iterators & Fail-Fast vs Fail-Safe
Last updated on