I created a class with 6 private static methods and a private constructor. The private constructor runs all of the static methods. I want to call the class’s private constructor in another class, but I’m not able to. All I want is to run this class once without creating an instance of anything. The class populates a small database and I have no need for it other than calling it once.
I could put it into a method, but I don’t want to put unrelated code into my main class. I want everything more separated. I could just do it with a public constructor and create an instance of the class, but I don’t see why I would have to do it that way when an instance isn’t needed.
Is there a good way to accomplish what I’m trying to do?
Why not replace your private constructor with a public static method?
Your original code:
Your new code
Than you call it: