Why string is popular hashmap key in java?
Answer / vishalshetkar
Since String is immutable, its hashcode is cached at the time of creation and it doesn’t need to be calculated again. This makes it a great candidate for keys in a Map and its processing is fast than other HashMap key objects. This is why String is mostly used Object as HashMap keys.
| Is This Answer Correct ? | 0 Yes | 0 No |
What is an exception in java?
Where is the find and replace?
Define interface in java?
What are the characteristics of Final,Finally and Finalize keywords.
What are null interfaces in JAVA ? and give me some examples?
how to make hashmap object as synchronized object?
What is I/O Filter?
Differences between jdk 1.4 and 1.5
6 Answers SoftSol, TCS, Wipro,
What is the need to implement Serializable interface (with no methods) for objects which are to be serialized ? We can write our own functionality which writes objects to streams then why we need to implement and tell JVM that which objects can be serialized.
Is empty .java file name a valid source file name?
In what type of containers, Border layout is a default layout?
Can Exception handling we can handle multiple catch blocks?