I am trying to figure out how to search a string for a certain number then if that number exists in the string do the following:
String str = "String4";
int myInt = 0;
public static void checkString(String str) // FIX ME
{
if(str.indexOf('3') == 0)
{
myInt = 3;
}
else if(str.indexOf('4') == 0)
{
myInt = 4;
}
else if(str.indexOf('5') == 0)
{
myInt = 5;
}
}
This never returns true though, is there an alternative way to search the string. There is a lot of extra code, but this method is the only thing causing the problem. I am pulling my hair out because of it, some help would be much appreciated!