Sitemap
Javarevisited

A humble place to learn Java and Programming better.

Member-only story

How to Write Less Code in Java 11 Using Lombok

--

Learn how to not have to implement getters, setters, and other methods for your Java applications by only using a few annotations.

Photo by on

Developing in Java can sometimes feel a little bit verbose. As programmers, we are always eager to write more code but wanting to do less at the same time.

Coming from a C# background, when I started programming in Java, I’ve always asked myself: How can I avoid having to write all these setters and getters? One day I was introduced to .

Project Lombok is an open-source library that helps you write less code in a few areas. Just to mention a few… you can avoid having to implement:

  • Getters and setters
  • Default or all argument constructors
  • toString methods
  • equals methods
  • hashCode methods

In this article, I’ll be going over a few of these annotations to help you get a better idea of how Project Lombok might be included as part of your Java application.

Setup

The first step will be to import Lombok to your application. In this example, I’ll be using for dependency management. I’ll be adding Lombok as one of my application’s dependencies. As of the writing of this…

Javarevisited
Javarevisited

Published in Javarevisited

A humble place to learn Java and Programming better.

tech.mia
tech.mia

Written by tech.mia

Passionate about coding. Engineering software one keystroke at a time… ⌨️

No responses yet