(if you don't know Java, don't bother reading on)
So, I've got this bit of code inside a for loop:
if(trainerList[f].indexOf(cmd) != -1)
{
blah blah
}
where cmd is a string read from the user via a Scanner, and trainerList is a string array (the for loop compares each item in trainerList to cmd in turn)
The problem is, it's case sensitive, so if the string cmd doesn't exactly match any of the strings in the trainerList[] array, nothing gets returned, which isn't what I want.
How can I make the if statement (ie the condition contained in it) not case-sensitive? (how it's done I don't care, as long as it works)
eg:
Currently "string" =/= "String", but I want "string" = "String".
Any help?
edit: resolved.
if(trainerList[f].toLowerCase().indexOf(cmd.toLowerCase()) != -1)
{
blah blah
}
worked a treat.