I am trying to initialize a static class, with an argument, and then run another static code in this class.
I know the static
block, but it seems like it cannot take any arguments.
Is there a way to pass arguments to a static constructor?
If not, what is the recommended method to initialize the Static class with an argument?
Edit: For my understanding, a static class is a class that cannot be created (in C # they are called static classes, if Java has a different term for them, sorry for not knowing about it) - it got access to him through the class name, the name of the object.
What I'm trying to achieve (very simplified) is a class that receives a dictionary as a String, parses it, and has methods that manage it like GetRandomEntry
.
Here is a snippet of code:
public class QuestionsRepository { private static Map<String,String[]> easyDefinitions = new HashMap<String,String[]>();
Accepting the appropriate parts of a code snippet is never easy, hopefully I chose wisely (:
Another detail that may be relevant is, as a rule, I am a C # programmer. Just started learning Java recently.
Thanks.
Oren a
source share