Java Collections Archive
In very short Encapsulation:– Information hiding. and Abstraction:– Implementation hiding. Abstraction vs Encapsulation Abstraction and Encapsulation both are OOP concepts of any object oriented programming languages which allow us to wrap real world things into …
We can remove duplicate items from ArrayList in java by simply converting ArrayList into Set in Java. But Set does not maintain insertion order as by List. So whenever we will convert ArrayList to HashSet …
Java Collections Framework are the fundamental aspect of java programming language. It’s one of the important topic for java interview questions. Here I am listing some important questions and answers for java collections framework.
We can sort the elements of: String objects Wrapper class objects User-defined class objects Collections class provides static methods for sorting the elements of collection.If collection elements are of Set type, we can use TreeSet. …
The HashMap class is roughly equivalent to Hashtable, except that it is non synchronized and permits nulls. (HashMap allows null values as key and value whereas Hashtable doesn’t allow nulls). HashMap does not guarantee that …
A Hashtable is an array of list.Each list is known as a bucket.The position of bucket is identified by calling the hashcode() method. A Hashtable contains values based on the key. It implements the Map …
Both TreeMap & HashMap are two different implementations of the Map interface. Even though this post is titled “TreeMap vs HashMap” I would like to say how they are connected and how much similar they …