-
Notifications
You must be signed in to change notification settings - Fork 2
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
3fdc6ee
commit 8e5f2ff
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
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,29 @@ | ||
import java.util.*; | ||
public class linked_hm{ | ||
public static void main(String[] args) { | ||
|
||
LinkedHashMap <String, Integer> lhm = new LinkedHashMap<>(); | ||
//in linked hashmap the way you insert the simmilar way result printing.. | ||
lhm .put("India", 100); | ||
lhm .put("Australia", 160); | ||
lhm .put("England", 60); | ||
|
||
|
||
HashMap <String, Integer> hm = new HashMap<>(); //here Random order it's printing. | ||
hm .put("India", 100); | ||
hm .put("Australia", 160); | ||
hm .put("England", 60); | ||
|
||
//Tree Map.. | ||
TreeMap<String , Integer > thm = new TreeMap<>(); | ||
//The treeMap is implemented using Red - Black BST .. | ||
//In TreeMap value are sorted according to 'Key' alphabetical order like- A B C D E F G ..X Y Z. | ||
thm .put("India", 100); | ||
thm .put("Australia", 160); | ||
thm .put("England", 60); | ||
|
||
System.out.println(lhm); | ||
System.out.println(hm); | ||
System.out.println(thm); // print base on 'key'.. | ||
} | ||
} |