I have a situation where I pass a constant to a constructor. I want to use an Enum, but I am not quite sure how to. My code looks something like this:
public class KeyPressedBehavior
{
public final static
String ENTER_KEY = "13";
public final static String ZERO_KEY = "48";
public final static String ONE_KEY = "49";
public final static String TWO_KEY = "50";
...
public KeyPressedBehavior(String keyPressed)
{
this.keyPressed = keyPressed;
}
private String keyPressed;
...
}
I am instantiateing KeyPressedBehavior like this:
new KeyPressedBehavior(KeyPressedBehavior.ENTER_KEY)
I am using this class to generate JavaScript that needs to know the ASCI decimal value of the key pressed.
How can I use an Enum instead of the messy constant code above, or can I?
Thanks,
Warren Bell