Hi all. My Data class is a singleton, there is a private constructor with one parameter and getInstance() method as following code:
In Sun's instructions, a user can put a database file's name via a GUI. When my application gets the database name, how can I push it into Data class, because my constructor can not be invoked direcly.
Perogi gave a good solution. Instead of just asking for more help, perhaps you could say what you see as being wrong with the solution given?
Alternative: have a setter method which sets the database name. Any attempts to get the instance of your Data class before the name is set will fail (with a suitable exception).
Another alternative: have the filename passed in as a parameter of the get instance method. That will have the added benefit of making it easy to change your Data class to a Multiton (instead of a Singleton) later.