When do we use hashset over treeset?
Answer / Shantanu Shukla
We use HashSet instead of TreeSet when the order of elements does not matter and performance is a concern, as HashSet has faster insertion and retrieval times compared to TreeSet due to its lack of ordering. However, if maintaining the order of elements (either ascending or descending based on natural ordering or custom Comparator) is important, we should use TreeSet.
| Is This Answer Correct ? | 0 Yes | 0 No |
How do you use spaces in java?
What are kinds of processors?
What is the difference between equals() and == in java?
Why is stringbuffer thread safe?
What is the difference between the jdk 1.02 event model and the event-delegation model introduced with jdk 1.1?
How do you set security in applets?
How do you remove an element from an arraylist in java?
what is the difference b/w static and final methods?
we have two threads..both the threads are reading the data.. is there any need of synchronization there?...justify it?
what is optional in java 8?
What are jee technologies?
What is the return type of read()?