Home » Java » Core Java » Page 4

Core Java

Facade Design Pattern In Java

Here I am with another article on design patterns – Facade Design Pattern. A Facade object is use to provide a simple interface by hiding complexities of a complex system. Facade Design Pattern The Facade is a Structural Design Pattern and one of the Gang of Four design patterns. The Facade object is used to provide a front-facing interface by masking a more complex underlying system.The Facade may provide a limited or dedicated ...

Read More »

How to create PDF File in Java – iText Example

Hello guys, generating PDF files in today’s enterprise applications is quite common. Doing this with Java is not an easy task as Java does not gives default api’s to handle PDF files. No worries, iText jar is for you. Earlier, I have shared about iText vs Apache FOP, two of the most popular libraries to create PDF files and today, ...

Read More »

State Pattern

Allow an object to alter its behavior when its internal state changes. The object will appear to change its class. Participants Context: defines the interface of interest to clients Maintains an instance of a ConcreteState subclass that defines the current state. State: defines an interface for encapsulating the behavior associated with a particular state of the Context. Concrete State: each ...

Read More »

Memento Pattern

Without violating encapsulation, capture and externalize an object’s internal state so that the object can be restored to this state later. Participants Memento: stores internal state of the Originator object. The memento may store as much or as little of the originator’s internal state as necessary at its originator’s discretion. Protect against access by objects of other than the originator. ...

Read More »

Inline array definition in Java

There are occasion when it is more convenient to create an array inline. Here are several way to declare and initialise primitive arrays and java.util.Lists type arrays. Declare a primitive array Primitive data types are the following: byte, short, int, long, float, double, boolean and char. Arrays of any of these types can be easily declared and initialised. 1 int[] ...

Read More »

Java Based Akka application Part 1: Your base Project

Akka is a free, open-source toolkit and runtime for building highly concurrent, distributed, and resilient message-driven applications on the JVM. Along with Akka you have akka-streams  a module that makes the ingestion and processing of streams easy  and Alpakka, a Reactive Enterprise Integration library for Java and Scala, based on Reactive Streams and Akka. On this blog I shall focus ...

Read More »

Start a Java app without installing it

This article describes how you can use JShell to download and execute a Java application. It will eliminate the need for the installation of the application. Do not install, just run! The first obstacle that you have to overcome to make people use your app is the installation.You want people to use the app, try it out.To do that, they ...

Read More »

Java 15: Sealed Classes

Java 15 introduces Sealed Classes, a preview language feature, that allows classes/interfaces to restrict which other classes/interfaces may extend or implement them. Here is an example: 1 2 3 4 5 public sealed class Vehicle permits Car, Truck, Motorcycle { ... }   final class Car extends Vehicle { ... } final class Truck extends Vehicle { ... } final ...

Read More »