I want to instantiate one instance of a class from the class name string. (using Class.forName (). newInstance ().)
Here's the problem: I want this instance to be a single. I could do this using a singleton pattern, except that newInstance calls the default constructor for the class, and with singleton, this constructor should be "private" ..
Is there a solution? I might think of a less elegant way to do this (using hashmap as a lookup table ..), but would prefer a better solution ..
Thanks,
source
share