-1

i perform a special action if the string equals something. However, i want to perform the same action if the string has uppercase characters. but i dont want to write so many else if statements for every case-

decrypt

Decrypt

DECRYPT

 } else if (message.equals("decrypt")) {
                        removeencryption(context);

is there a way of removing case sensitivity?

i have already tried

} else if (message.toLowerCase().equals("whistle")) {
                    whistle(context);

but it is not working

Emily
  • 121
  • 7

1 Answers1

0

Use equalsIgnoreCase method of String class:

else if (message.equalsIgnoreCase("decrypt")) {
                        removeencryption(context);
}
Misagh Emamverdi
  • 3,654
  • 5
  • 33
  • 57