Porixify Porixify - 3 months ago 17
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?


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