Professional Documents
Culture Documents
- Random Access
- ArrayList manuplation is slow because lot of bit shifting is required when we adding and
removing an elements
LinkedList:
It is synchronized class
HashSet:
- No duplicate
LinkedHashSet
- No duplicate allowed
TreeSet: - No duplicate
HashMap:
LinkedHashMap: it is same as hashMap only the difference is it LinkedHashMap maintain the instertion
order.
HashMap VS HashTable
ConcureentHashmap divides the map into the segment and put the lock on one of the segment not the
whole map.
No other thread can access the Locked Segment . But they can access the rest of the map and can only
perform the read operation.
ConcurrentHashMap vs HashTable
Fail Fast: while doing the iteration in the collection if it throws the ConcurrentModificationException
that is called fail fast
Fail Safe: while doing any modification at the iteration time will not get any
ConcurrentModificationexception that class is fail safe class
Comparable Vs Comparator
Comparable : it provides a single sorting Sequence. E can sort the object based on the single element of
the class.
Comparator interface: it provides the Multiple Sorting Sequence which means it will do the sorting
based on the Multiple elements of the class.
Equals Method: in object class is checking the reference .it works like == in string
If we are overriding the hashcode it will first check it there are two objects same it will return the same
hashcode for that two objects.
And equals() method will compare the value of the object and return true if both are same else return
false.
After overriding the equals into the class it will compare the value of the object not the reference.