Hashtable in Java

We will find out answers for the following question What is Hashtable Common methods available Hashtable HashTable is a member of the Java Collection Framework as it implements Map Interface. HashTable implements a hash table, which maps keys to values. Any non-null object can be used as a key or Read more…

HashMap in Java

We will find out answers for the following question What is HashMap in Java Common methods available HashMap HashMap is a Map-based collection class that is used to store Key & value pairs. It is denoted as HashMap<Key, Value> or HashMap<K, V>. This class makes no guarantees as to the Read more…

Hashing Technique

We will find out what are Hash functions, Hashcode, Collision and Rehashing. Since HashMap and HashSet both use Hashing Technique we will also be able to answer Internal working of HashMap Internal working of HashSet Hash functions Hash functions are used in hash tables, to quickly locate a data record (e.g., Read more…

String is immutable

Overview We will find answers for the following questions What is String pool? How does memory allocation work for String? Why is String immutable. String pool String pool is a special storage area in Java heap. When a string is created and if the string already exists in the pool, Read more…

Collection Framework in Java – Overview

What Is a Collections Framework? A collections framework is a unified architecture for representing and manipulating collections. All collections frameworks contain the following: Interfaces Implementations Algorithms Benefits of the Java Collections Framework Reduces programming effort: By providing useful data structures and algorithms, the Collections Framework frees you to concentrate on Read more…

Sorting in Java (Comparator)

In my previous post, we saw Comparable and it’s implementation. Java provides another way to compare objects. Instead of implementing the comparable interface, we can implement the Comparator interface. The main difference between these two interfaces is that the comparable interface defines one method compareTo(), which takes one parameter. The Comparator interface defines Read more…