in Technology by
What is the difference between HashMap and TreeMap in JAVA?

1 Answer

0 votes
by
The differences between the HashMap and TreeMap are given below. HashMap maintains no order, but TreeMap maintains ascending order. HashMap is implemented by hash table whereas TreeMap is implemented by a Tree structure. HashMap can be sorted by Key or value whereas TreeMap can be sorted by Key. HashMap may contain a null key with multiple null values whereas TreeMap cannot hold a null key but can have multiple null values.

Related questions

0 votes
    What is the difference between HashMap and Hashtable in JAVA?...
asked May 26, 2021 in Technology by JackTerrance
0 votes
    What is the difference between HashSet and HashMap in JAVA?...
asked May 26, 2021 in Technology by JackTerrance
0 votes
    What is the difference between heat map and treemap of Tableau?...
asked Oct 30, 2020 in Technology by JackTerrance
0 votes
    When I iterate over the values or keys are they going to correlate? Will the second key map to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 12, 2022 in Education by JackTerrance
0 votes
    What happens if we put a key object in a HashMap which exists? (a) The new object replaces the ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    Is hashmap an ordered collection. (a) True (b) False I had been asked this question during an ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    If two threads access the same hashmap at the same time, what would happen? (a) ConcurrentModificationException ... and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    What is the difference between the length of an Array and size of ArrayList in Java?...
asked May 27, 2021 in Technology by JackTerrance
0 votes
    What is the difference between Collection and Collections in JAVA?...
asked May 26, 2021 in Technology by JackTerrance
0 votes
    What is the difference between Set and Map in JAVA?...
asked May 26, 2021 in Technology by JackTerrance
0 votes
    What is the difference between HashSet and TreeSet in JAVA?...
asked May 26, 2021 in Technology by JackTerrance
0 votes
    What is the difference between List and Set in JAVA?...
asked May 26, 2021 in Technology by JackTerrance
0 votes
    What is the Main difference between Iterator and Enumeration in JAVA?...
asked May 18, 2021 in Technology by JackTerrance
0 votes
    Difference between Core Java and Advance Java?...
asked Dec 21, 2020 in Technology by JackTerrance
0 votes
    What is difference between dequeue() and peek() function of java? (a) dequeue() and peek() remove and ... Collections Framework of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
...