Why would I use a Singleton instead of a simple:
1. final
2. private constructor
3. static methods
Class?
I've heard that "static classes" cannot implement interfaces, but Singletons can... I don't know the language the article was talking about, but, in my code (Java), I can easily implement any interface and restrict acess directly into this class.
Here is an example of my code:
public final class CsvRandom {
private CsvRandom(){}
public static String getRandomValue(@NotNull String path) throws IOException, IllegalArgumentException {
...
}
}
But couldn't I go to the class with static methods and those kind of things and change those things there?