What are the differences between Helper and Utility classes?

There are many naming styles to use. I would suggest Utils just because its more common.

A Utility class is understood to only have static methods and be stateless. You would not create an instance of such a class.

A Helper can be a utility class or it can be stateful or require an instance be created. I would avoid this if possible.

If you can make the name more specific. e.g. if it has sorting methods, make it XSorter

For arrays you can find helper classes like

Array
Arrays
ArrayUtil
ArrayUtils
ArrayHelper

BTW a short hand for a utility class is an enum with no instances

enum XUtils {;
    static methods here
}

If you need to implement an interface, I would use a stateless Singleton.

enum XHelper implements RequiredInterface {
   INSTANCE;
   // no instance fields.
}

Leave a Comment