Gson Jackson To Map JSON To POJO And POJO To JSON

Introduction This tutorial will show you how you can map JSON string to a list of POJO objects and a list of POJO objects to JSON string using Google API’s Gson as well as Jackson API’s ObjectMapper. I will create nested POJO objects from JSON string or JSON string to nested POJO objects using both Gson and Jackson API.

ArrayList vs LinkedList in Java

List ArrayList and LinkedList are two popular concrete implementations of List interface from Java’s popular Collection framework. Being List implementations both ArrayList and LinkedList are ordered, index based and allows duplicate. In this tutorial we will discuss what are the similarities and differences found between ArrayList and LinkedList.

Shallow Copy And Deep Copy In Java

Shallow Copy/Deep Copy Shallow Copy also means Shallow Clone and Deep Copy also means Deep Clone. Cloning an object is about creating the copy of the original object, i.e., making an identical copy of the original object. By default, cloning in Java is field by field copy i.e. as the Object class does not have idea about the structure of…

Injecting properties value in Spring

This tutorial will show you how we can auto inject value from properties file in Spring. For this tutorial we will create a standalone maven project in Eclipse. If you already have an idea on how to create a maven project in Eclipse will be great otherwise I will tell you here how to create a maven project in Eclipse….

State Design Pattern in Java

Introduction State pattern comes under behavior design pattern in JEE. The State design pattern allows an object to alter its behavior when its internal state changes. State pattern is used to provide a systematic and lose-coupled way to achieve this through Context and State implementations. Context is the class that has a state reference to one of the concrete implementations…

Strategy Design Pattern in Java

Introduction The strategy pattern is a behavioral design pattern that enables an algorithm’s behavior to be selected at runtime without causing tight coupling. The strategy pattern defines a family of algorithms, encapsulates each algorithm, and makes algorithms interchangeable. Strategy pattern lets the algorithm vary independently from clients that use it. So you define a strategy wherein a particular algorithm or…

Observer Design Pattern in Java

Observer Pattern is one of the behavioral patterns. Observer design pattern is useful when there is something need to be done with the state of an object and an object wants to get notified whenever there is any change in state. In observer pattern, the object that watches on the state of another object are called Observer and the object…

Memento Design Pattern in Java

Table of Contents Introduction Prerequisites Memento Design Pattern Implementation Main Class Output Source Code Introduction Memento Pattern is one of the behavioral patterns. Memento pattern is a software design pattern that provides the ability to restore state of an object to its previous state. The memento design pattern is implemented with three objects: the originator, a caretaker and a memento….

Mediator Design Pattern in Java

Mediator Pattern is one of the behavioral patterns as it deals with the behavior of the program. Usually a program is made up of a large number of classes. So the logic and computation are distributed among these classes. As more classes are developed in a program, the number of classes are increased, thus arising the problem of communication among…

Iterator Design Pattern in Java

Iterator pattern falls under behavioral design pattern. Iterator pattern is very commonly used design pattern in Java. This pattern is used to iterate through a collection of objects without exposing its underlying representation. It is used to access the elements of an aggregate object sequentially. For example, Java’s collections like ArrayList and HashMap have implemented the iterator pattern.