Commit 80c3c8d0 authored by Qazi Zain's avatar Qazi Zain

Map code is added

parent edcbcf08
package MapInterface.CoustomHashMap;
import java.util.*;
public class CoustomHashMap
{
HashMap<Integer,String> obj = new HashMap<>();
CoustomHashMap()
{
System.out.println("Coustom HaspMap object is created!");
}
void displayHashMap()
{
// add value in HashMap.
obj.put(1,"zain");
obj.put(2,"ali");
obj.put(3,"zain"); // value iss duplicate and key is unique it will add.
obj.put(1,"zain"); // this will not add because key isn't unique.
System.out.println("Values in Hash Map:"+obj);
// Searching in map.
if(obj.containsKey(2))
{
System.out.println("ali is in hash table as a record");
}
// get value
System.out.println("value of key 3 is:"+obj.get(3));
}
}
package MapInterface.CoustomHashMap;
public class Main {
public static void main(String[] args) {
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment