1// Implement tree map in Java
2
3import java.util.SortedMap;
4import java.util.TreeMap;
5
6public class CreateTreeMapExample {
7 public static void main(String[] args) {
8 // Creating a TreeMap
9 SortedMap<String, String> fileExtensions = new TreeMap<>();
10
11 // Adding new key-value pairs to a TreeMap
12 fileExtensions.put("python", ".py");
13 fileExtensions.put("c++", ".cpp");
14 fileExtensions.put("kotlin", ".kt");
15 fileExtensions.put("golang", ".go");
16 fileExtensions.put("java", ".java");
17
18 // Printing the TreeMap (Output will be sorted based on keys)
19 System.out.println(fileExtensions);
20 }
21
22}
23