Home » Java » Core Java (page 3)

Core Java

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 »

Java Projects: Book Review

This article is about the book Java Projects Second Edition, by Peter Verhas that I wrote last year. The aim of such an article is usually to boost the sales of the book. It is no different in this case, but since this is a book that I wrote, and I am the person, who is writing the review it ...

Read More »

Object and Index Streams

I was going to write a post about how to blend a stream with the indices of each element, but the folks over on Baeldung have covered this subject enormously well! Given I’m part of their editorial team, I’m proud of them/us. It’s interesting how functional programming in Java, Streams especially, have trained us out of some common patterns. Example: ...

Read More »

How To Deep Clone An Object Using Java In Memory Serialization

In my previous articles, I had explained the difference between deep and shallow cloning and how copy-constructors and defensive copy methods are better than default java cloning. Java object cloning using copy constructors and defensive copy methods certainly have some advantages but we have to explicitly write some code to achieve deep cloning in all these approaches. And still, there ...

Read More »

How to Customize Serialization In Java By Using Externalizable Interface

In a previous article Everything About Java Serialization Explained With Example, I explained how we can serialize/deserialize one object usingSerializable interface and also explain how we can customise the serialization process using writeObject and readObject methods. Disadvantages Of Java Serialization Process But these customizations are not sufficient because JVM has full control of the serialization process and those customization logics ...

Read More »

Java: An Optional Implementation of Optional

The class java.util.Optional is implemented as a single immutable concrete class that internally handles two cases; one with an element and one without. Wouldn’t it have been a better choice to let Optional be an interface and have two different implementations implement that interface instead? After all, that is what we generally are taught to do in an object-oriented language. ...

Read More »