As per this
Underlying data structure for HashSet is hashtable.
But I have also read that HashSet internally uses HashMap to avoid duplicate values which in turn internally uses array of buckets and LinkedList(replaced by tree in Java 8)
So is it right to say that HashSet uses HashTable as data stucture and HashMap as collection?
TreeSet implements the SortedSet interface so duplicate values are not allowed.
Does that mean that TreeSet doesn't uses HashMap internally which is used by HashSet to avoid duplicate values?Does LinkedHashSet uses HashMap internally?
As per this
Memory point of view arrays are not recommended to use.
Why? By what i read before-
Since ArrayList can’t be created for primitive data types, members of ArrayList are always references to objects at different memory locations (See this for details). Therefore in ArrayList, the actual objects are never stored at contiguous locations. References of the actual objects are stored at contiguous locations. In array, it depends whether the arrays is of primitive type or object type. In case of primitive types, actual values are contiguous locations, but in case of objects, allocation is similar to ArrayList.