How to remove duplicate elements from ArrayList in Java

How to remove duplicate elements from ArrayList in Java Many times we need to remove duplicate or repetitive elements from the ArrayList because ArrayList dont check for duplicates. We will use HashSet to remove duplicates from the ArrayList. [...]
HashMap Interview Questions and Answers

5 interview questions and answers on HashMap in Java

5 interview questions and answers on HashMap in Java. HashMap is one of the widely used type of Collection in Java. So it is very important to know some of the key things in HashMap such as How HashMap works, HashMap get() and put() methods, [...]
How HashMap works in java

How HashMap works in Java

How HashMap works in Java How HashMap works in Java or do you know Hashmap in java is one of the most asked interview question in java. As it checks your knowledge about the collection as HashMap is one of the mostly needed and used Collection [...]
Difference between ArrayList and Vector in java

What is the difference between ArrayList and vector in java

What is the difference between ArrayList and vector in java? This is one of the favorite interview question and very important to know the difference between the two because we need to use lot of those collection while writing the code. So [...]

How to create and use Hashtable?

This post explains implementation of Hashtable. We can find this class in java.util. Hashtable maps keys to values , these keys and values can be any non null objects. Hashtable uses hashing function algorithm so the object which we use for [...]

How to list elements in Collection in java?

We can use Iterator to list the elements in java. We can use Iterator’s hasNext() and next() methods to list the elements in Collection. hasNext() method is used to check the whether collection contains any more elements, so we can use [...]

Double brace initialization in java

As the name suggest this (hidden or not so famous) feature allows initialization in java in short cut way. Now lets look how double brace initialization works. Lets first consider the normal initialization way , suppose we are initializing the [...]

What is the difference between Comparator and Comparable in java?

Comparable This interface comes from the java.lang package. When a class implements this interface , the class imposes a natual order for itself and comparison scheme with the method compareTo. List of objects which implements this interface [...]

TreeSet in Java

How to use TreeSet in Java : TreeSet in java is a class which implements Set interface. Let see few characteristics of TreeSet in java before taking look at java treeset example. TreeSet in java 1. TreeSet in java guarantees sorted set of elements [...]

How to use HashSet in Java?

HashSet : HashSet implements Set interface. To store the values it uses Hashtable internally which uses hashing mechanism. Because of Hashing there are two advantages, first because it is used to find duplicates using the key and second is [...]
Page 1 of 212