ServletContext and load-on-startup

What happens behind the scene when Web Application is deployed in Web Server like Tomcat? ServletContext It provides a set of methods that a servlet uses to communicate with its servlet container. There is one context per “web application” per Java Virtual Machine. A “web application” is a collection of servlets Read more…

Difference between Hashtable and HashMap

Based on my previous posts related to Hashtable and HashMap let’s see the difference. HashMap Hashtable Non-Synchronized. Fast. Synchronized. Slow Allows one null key and any number of null values. Hashtable doesn’t allow null keys and null values. Use LinkedHashMap to maintains the insertion order. TreeMap to sort mappings based on the ascending order of Read more…

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…

Primitive vs Wrapper Class in Java

Overview In this Blog we will find answer for following questions What is Primitive Type. What is Wrapper Class. Convert one into another. Ideal scenario to use Primitive vs Wrapper. Primitive Type Primitive types directly contain values. Java defines many primitive type variables. We will see mainly int vs Integer. 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…