Java – should classes with only static methods be abstract?
•
Java
I have a class that provides a set of static utility type methods
On the one hand, I don't want this class to be instantiated On the other hand, I don't want to signal that the class should inherit (not that I think it's possible)
Should this class be abstract?
Solution
Make the class final and the default constructor private, and do not provide any public constructors In this way, no one can subclass it or create an instance of it
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码