top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Java: How to decide between HashMap and TreeMap?

0 votes
501 views

What is the key difference between a HashMap and a TreeMap and what should be the key factor to choose HashMap or a TreeMap?

posted Mar 14, 2016 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Because HahsMap gives better performance if you don’t need sorting then go for HashMap otherwise TreeMap would be choice. You have also option available to use LinkdeHashMap which is same fast as HashMap including it gives remove/add/contains functionality and also maintains insertion order.

answer Mar 16, 2016 by Shubham Singh
...