If I have to design a Utility class( such as ByteUtils or StreamUtils or StringUtils), what is the best design choice for them.
- Should they be static classes (as I won’t have any states to store)
- Should they be non-static classes ( so that if the objects are not used, they will be gc’d)
PS: By static class, I meant a class with static methods(and not the inner static class)
Please give advice on design choices for this ?
If it is a general purpose utility, static is IMO better. You stated that you will not have any states to store, so I don’t see why should you make it non-static. Declaring it to be static will save memory too.