Home » Java » Core Java (page 7)

Core Java

Observer Design Pattern In Java

In this tutorial, we’ll talk about the Observer design pattern. There are two main aspects to the observer pattern – a Subject and the Observers. We use this pattern when our system has multiple objects, known as the observers, relying on the state of one particular object – the subject. All the observers register themselves to the subject. Whenever there ...

Read More »

Template Method Pattern In Java

The template method pattern is a behavioral pattern which suggests defining an algorithm more generally in the superclass. The algorithm is defined within a method known as the template method. The subclasses only define the implementation of the more specific algorithmic steps. The benefit of using this design pattern is that any changes later in the algorithm will only impact ...

Read More »

Decorator Design Pattern In Java

A decorator design pattern allows dynamically attaching the additional responsibilities or behaviors to an object at runtime. It is a structural pattern and makes use of aggregation to combine those behaviors. In this tutorial, we’ll learn to implement the decorator pattern. UML Diagram: Let’s start by looking at the UML representation of a decorator pattern: The ConcreteComponent class is the ...

Read More »

Proxy Design Pattern In Java

Proxy objects or the surrogates provide a placeholder for another object to control access to that object. A proxy acts as a lightweight or the simplified version of the original object. It supports the same operations as the original object but may delegate those requests to the original object to achieve them. The Proxy design pattern is a structural pattern ...

Read More »

Factory Method Design Pattern

Factory Method pattern is one of the popular creational design patterns. It doesn’t specifically rely on a factory object to create the objects. Rather, the idea is to use a separate method in the same class to create an object. Factory Method pattern defines an interface for creating objects but lets the subclasses decide how to instantiate its objects. Each ...

Read More »

Facade Design Pattern In Java

Facade means the face of a building. While passing across a street, all we look at is the face of a building. The face abstracts all the complex implementation details of a building. Similarly, a facade design pattern aims to provide a unified interface to a set of interfaces in the subsystem. This unified interface hides the subsystem complexity from ...

Read More »

Composite Design Pattern In Java

A composite design pattern is useful when we have to work with a tree-like hierarchical structure of objects. It lets us treat the individual objects and the composition of objects uniformly. It falls under the category of a structural design pattern as it composes objects into a tree structure to represent part-whole hierarchies. UML Representation: The UML representation of a ...

Read More »

How to Use Lombok to remove boilerplate setters getters in Java

Hello Friends, One of the points which is said time and again against Java is that ,we have to write a lot of boilerplatecode in the form of setters and getters for our simple POJO classes which unnecessarily increases thelength of our code. To tackle this problem,there is an open source project called Project Lombok which solves this problemby allowing ...

Read More »

The 8 Primitive Types in Java

As I begin to edit my Java Basics series from a couple years ago, I thought it would make sense to start pulling some really detailed information out into their own posts. That way, the beginner content is much easier to digest. To start, I’m pulling out all the information I have on the 8 primitive types in Java. Java ...

Read More »