Why its important to use private 0arg constructor for Java
When creating util classes in java you should ensure you add a 0arg private constructor
Util classes are classes which have only static methods and are not intended to be constructed by new.
This to ensure that it is not possible to create the class with new
. Theres no point! Utils should be static!
What you should put
private constructor() {
// no code here
}
This is important as it ensures that util classes will not be instantiated and therefore will not cost the application memory in redundant areas.