Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
32 lines (31 loc) · 864 Bytes

File metadata and controls

32 lines (31 loc) · 864 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package collection.Map;
import java.util.Map;
import java.util.TreeMap;
/*
Value Associated with key 'two'= 2
Keysets: [one, seven, six, two]
Entry of map: [one=1, seven=7, six=6, two=2]
Size of map: 4
one : 1
{one=1, seven=7, six=6, two=2}
*/
public class TreeMapExample {
public static void main(String[] args) {
Map<String,Integer> m=new TreeMap<>();
//Treemap sorts according to key
m.put("six", 6);
m.put("one", 1);
m.put("two", 2);
m.put("seven", 7);
System.out.print("Value Associated with key 'two'= "+m.get("two")+"\n");
System.out.print("Keysets: "+m.keySet()+"\n");
System.out.print("Entry of map: "+m.entrySet()+"\n");
System.out.println("Size of map: "+m.size());
if(m.containsKey("one")) {
Integer x=m.get("one");
System.out.println("one : "+x);
}
if(!m.isEmpty())
System.out.println(m);
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.