J
John E
What is the best way to store a string equivalent of an integer in Java?
"January" = 1
"February" = 2
etc...
TIA
"January" = 1
"February" = 2
etc...
TIA
John E said:What is the best way to store a string equivalent of an integer in Java?
"January" = 1
"February" = 2
etc...
TIA
Jarmo said:Using a Hashtable? For example:
Hashtable hash = new Hashtable();
hash.put("January", new Integer(1));
hash.put("February", new Integer(2));
However if you genuinely are just working with months then you might be
coming at this from the wrong angle. Typically you'd use integers to
represent the months and then have an array of month-names.
John E said:What if I had to randomly generate two possible textual values? e.g. "Heads"
and "Tails"?
"January" = 1
"February" = 2
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.