Hi guys, I'm creating a version of my microinterpreter in java and I need to know about some few things. The program in java is working nicely but because my lack of knowledge in java properly, I added the tokens on my tokenizer manually. I want to create a table where I can add new tokens easly without need to add it manually.
So, I created a util class where I putted??? some utility functions and where I putted?? my token table. See below:
See, so, how can I put this in a static table? I was thinking in Hashtable class but how can I add information to it statically? I dont want to instanciate the ScriptCommon class, I tryed this:
But this code doesnt compile...
Any sugestions ? Remember, I want it statically... a vector???
Thanks in advance!
You would probably be better off putting them in a properties file and then loading the properties file at runtime into a Properties Object. A Properties object extends Hashtable so you would be able to access the key values pairs in the same way you do now but the key value pairs would be in a text file so you can add new values without having to recompile your code.
If you really want to do it in a static class then use a static initializer to load the values into the Hashtable which BTW should really be a HashMap.