Skip to content

Commit

Permalink
making of hashmaps
Browse files Browse the repository at this point in the history
  • Loading branch information
Ankush1oo8 committed Mar 13, 2024
1 parent 4f0cedd commit f7c126c
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Hashing/hashmap.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package Hashing;
import java.util.*;
public class hashmap {
public static void main(String[] args) {
HashMap<String,Integer> h=new HashMap<>();

//insertion
h.put("India", 100);
h.put("China", 150);
h.put("Paki", 50);
System.out.println(h);

//get operation
int population=h.get("India");
System.out.println("Population of india is : "+population);

//contains key
System.out.println(h.containsKey("paki"));
System.out.println(h.containsKey("Paki"));//case sensitive

//remove
h.remove("China");
System.out.println(h);

//size
System.out.println(h.size());
System.out.println();
//clear
h.clear();
//is empty
System.out.println(h.isEmpty());

}
}

0 comments on commit f7c126c

Please sign in to comment.