Im trying to cast a char to a string, but if i just define equality, the complier says incompatible types.
I looked in my textbook but it only shows how to cast ints and doubles.:sad:
I have to write a class that takes a char and a String. It then searches the string for the char and returns a boolean.
Im useing a scanner to do this, and it will only accept a string, not a char. Maybe I'm going about this all wrong, if so, please point me in the right direction.
Thanks
Colin
public static boolean isThere(char sreachChar, String stringToSreach)
{
String stringToSreachLower = stringToSreach.toLowerCase();
String stringToSreachUpper = stringToSreach.toUpperCase();
String sreachString=sreachChar;//WTF???
Scanner stringScannerLower = new Scanner(stringToSreachLower);
Scanner stringScannerUpper = new Scanner(stringToSreachUpper);
String text = key.readWord();//inputs up to white space
key.readLine();//Clear input buffer
if(stringScannerLower.findInLine(sreachString) == sreachString | stringScannerUpper.findInLine(sreachString) == sreachString)
{
return(true);
}
else
return(false);
}