-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f0cedd
commit f7c126c
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
|
||
} | ||
} |