Porixify Porixify - 1 year ago 73
Java Question

How would I go about comparing two character that will convert to the same character?

So basically, I want to use the switch statement. I have a chart for each encoded character that a user will enter. However, each uppercase character and lowercase character has the same meaning. I find it unnecessary to copy each switch statement and revise the same thing. So how would I come about this?

Answer Source

You can use the function toUpperCase:

Converts the character argument to uppercase using case mapping information from the UnicodeData file.

switch (Character.toUpperCase(character)) {
    case 'A':
        // code ...
    case 'B':
        // code ...
        // default code
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download