new
keyword.
In utility classes, all fields and methods are static
.
Instantiation of such classes is most likely unnecessary and indicates a mistake.
Example:
class MyUtils { public static double cube(double x) { return x * x * x; } } class Main { public static void main(String[] args) { // Instantiation of utility class MyUtils utils = new MyUtils(); } }
To prevent utility classes from being instantiated,
it's recommended to use a private
constructor.