Learn when to use setter methods or constructors for setting the value of a variable in Java.
Search Results for: const
Overview of Mockito MockedConstruction
A quick and practical guide to Mockito’s MockedConstruction.
How to Mock Constructors for Unit Testing using Mockito
Learn different ways to mock constructors through Mockito and PowerMock.
Constructing Java Objects From Only the Class Name
Explore the process of creating Java objects using their class names.
Lombok’s @RequiredArgsConstructor Annotation
Learn how the @RequiredArgsConstructor annotation of Lombok can help auto-generate constructors for classes.
Need for Default Constructor in JPA Entities
Learn about the JPA requirement for a default no-argument constructor in an Entity class.
Custom Constructor in Java Records
Learn how to create custom constructors for Java Records and the benefits they provide.
Accessing Private Constructor in Java
Learn why and how to use a private constructor for a class in Java.
Fix the IllegalArgumentException: No enum const class
Why IllegalArgumentException is thrown and how to fix in it in Java.
Variable Instantiation on Declaration vs. on Constructor in Java
Learn that using either field declaration or constructor initialization is more of a preference.
Constructing a Relative Path From Two Absolute Paths in Java
Learn how to construct a relative path from two absolute paths in Java.
Constraint Composition with Bean Validation
Learn how to group multiple constraints under a single, custom annotation to reduce code duplication and improve readability
Constructor Specification in Java
Learn the rules that Java language specified for the declaration of a constructor
Java Implicit Super Constructor is Undefined Error
Learn about Java’s “implicit super constructor is undefined” error and how to resolve it
Solving the Hide Utility Class Public Constructor Sonar Warning
We may produce utility classes with static methods in Java and then receive a warning from Sonar about the implicit public constructor. We look at how to handle this error and some alternative implementations for static modules.
Constructors in Java Abstract Classes
A quick and practical guide to using constructors in abstract classes.
Chaining Constructors in Java
Learn how to chain constructors in Java.
Throwing Exceptions in Constructors
Learn about throwing exceptions in a constructor.
Private Constructors in Java
Learn about private constructors in Java.
Defining Unique Constraints in JPA
Learn how to define unique constraints on entity classes in JPA and Hibernate.