package codeAegon;

import java.util.*;

/**
 * 
 * @author k nityan suman
 *
 */

class HashMapsDemo {
	// TODO class showcasing the use of hashmap data structure
    public static void main(String[] args) {
        // declare a string to string hashmap
    	HashMap<String, String> myMap = new HashMap<>();
        
        myMap.put("Hi!", "Hey!"); // add key-value pair to the hash map
        myMap.put("Hello!", "Hola!");

        System.out.println("Key = Hi! and Value = " + myMap.get("Hi!")); // obtain values based on key
        System.out.println("Key = Hello! and Value = " + myMap.get("Hello!"));

        // each key is associated with only one value
        myMap.put("Hi!", "Bye!");
        // only one Hi keys is present and the values is changed to the latest one i.e., Bye!
        System.out.println("Key = Hi! and Value = " + myMap.get("Hi!"));

        System.out.println("Entire Hashmap => " + myMap); // get the entire hashmap
        
        // check if a key is present
        System.out.println("Is key = Bye! present ? (y/n) " + myMap.containsKey("Bye!")); // check if a key is present
        System.out.println("Is key = Hello! present ? (y/n) " + myMap.containsKey("Hello!"));
    }
}