Is it bad practice for a class to have only static fields and methods?

后端 未结 14 741
予麋鹿
予麋鹿 2020-11-30 03:05

I have a class that consists only of static member variables and static methods. Essentially, it is serving as a general-purpose utility class.

Is i

14条回答
  •  无人及你
    2020-11-30 03:20

    Sounds reasonable.

    Note: Classes that do this often have a private no-arg constructor just so that the compiler yields an error if a programmer tries to create an instance of the static class.

提交回复
热议问题