Question

For example, if I wanted if I wanted to parse the input arguments from a Java program and use the input option as a key to get a variable name... i.e.

java optionTable 
------------------------------------------------------
option | option help | internal option variable name | 

I could implement this using brute force tactics, such as making an array of lists. Then creating a HashMap that maps array index to option name. But, it would be nice to know if there is an actual implementation for this?

Any comments/ "why don't you just use this are welcomed."

Was it helpful?

Solution

Basically, you need a structure. In Java these are implemented in terms of classes.

So your ID maps to a object of a class which has all the needed fields.

For instance:

class Val {
     string OptionHelp;
     string InternalName;
}

and then you use HashMap

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top