![]() |
A TreeMap is a component of the Java Collections Framework in Java. A TreeMap is immutable which means it cannot be changed once it has been created. This implies that you are unable to add, delete, or change any items after the TreeMap has been created. In this article, we will learn how to create an immutable TreeMap in Java. Syntax of Creating a TreeMap:TreeMap<Integer, String> tp = new TreeMap<Integer, String>();
Program to Create an Immutable TreeMap in JavaBelow is the implementation of Creating an Immutable TreeMap: Java
Output
Immutable TreeMap: {Five=5, One=1, Three=3} Explanation of the above Program:
Benefits of Immutability in Java
|
Reffered: https://www.geeksforgeeks.org
Java |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |