I always forget about String.equals(). Just to be safe, I always like to store the char value in another String object, trim that new String using String.trim(), and then upper-case it using String.toUpperCase() for a case “insensitive” compare.
I keep referring back to my “function router” to remind myself how to do it.
int fnRouter(String command) {
command.trim();
command.toUpperCase();
if(command.equals("SECONDS"))
return millis()/1000;
...
.trim() is great when you’re not sure where your data is coming from, but if you know… then you can speed it up by just doing the .equals() comparison. Also if you are not sure about the case of your data, you can use
if (string1.equalsIgnoreCase(string2)) {
// is string1 equal to string2 ignoring case?
}