Answer Posted / 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 |
Post New Answer View All Answers
What is string in java?
What are the main uses of the super keyword?
What is an example of procedure?
What package is math in java?
How many types of classes are there in java?
What are methods?
What is null mean in java?
How many JVMs can run on a single machine and what is the Just-In-Time(JIT) compiler?
Is set ordered in java?
What is the difference between notify and notifyall method?
What are the major advantages of internal iteration over external iteration?
Explain about method local inner classes or local inner classes in java?
Can we return null in java?
What is operator overloading. Is it is supported in java?
Why java is called not pure object oriented language?