HashMap in Java

how hashmap works java

What is Hashing? Hashing is a mechanism to convert one value to another. The process which performs this transformation is called the ‘Hash Function’. The input to the hash function is normally called as the ‘Key’ and this could be any value which can be converted to a String. The output or the hashed value … Read more

Variable Handle In Java 9

Variable Handle In Java 9

What Is A Variable Handle? A Variable Handle or VarHandle is nothing but a typed reference to a variable created in order to provide read and write access to the variable under different access modes. The variables can be array elements, instance or static fields in a class. VarHandle objects cannot be modified once they … Read more

The Factory Method Design Pattern

What is Factory Method Design Pattern? Gang of Four categorizes the factory method design pattern as a creational pattern since it deals with object creation.  This pattern enforces the loose coupling and encapsulation principles in object-oriented programming. This pattern applies in situations where there are sub-classes involved, and the creation of those becomes complex with … Read more

What is Dependency Injection Design Pattern?

The software world is getting more robust and smart with blooming innovative ideas every day. Every technology is lightened by this smartness which reduces the heavy and complex mechanisms. Emerging frameworks are best examples of those innovations. Those are capable of making the designers and developers’ lives less stressful with many automated features. Containers are … Read more

Multi-Release JARs in Java 9

While developing Java-based solutions, one would have to often include third party libraries to code better. These third-party libraries usually release different releases according to the support matrix they have. This would result in having different library versions targeted for different Java versions. As a result, it would be difficult to ensure that everything works … Read more

Let’s Learn Singleton Design Pattern

What is a Singleton? The word singleton is derived from the word, Single which represents one independently executable unit. In the programming world, a singleton is an object which has only one instance for the life time of the application. What is Singleton Design Pattern? Singleton design pattern is classified as a creational design pattern … Read more

Convenience Factory Methods For Collections In Java 9

In order to create an immutable collection before Java 9, a Java developer had to write code which involves creating a collection, adding elements to it and passing the collection to Collections.unmodifablexxx() method where xxx can be any collection like a set or a list. As a result, the program becomes too verbose. A Java … Read more

Java Tree Data Structure

In this tutorial, we would be creating a Tree data structure in Java. Java does not have a built in tree data structure. Let’s start by creating a tree as shown in the below image. The tree has a Root node and a number of children Java Tree Implementation Building Tree In Java Tree, each … Read more

Java 8 streams – List to Map examples

In this tutorial, we would be looking at the various examples of using streams introduced in Java 8 to create a Map from a List of values. I have been working with Java 8 for quite a while and have found streams extremely useful. Almost every single day I am writing code using streams.  We … Read more