Image

Imagemgrjoe wrote in Imagejava_dev 😟distressed

what method for String

Ok, here I am again...

The problem I was working on is still a wench, but I'm getting there.

public class IfElse
{
public static void main(String[] args)
{
System.out.println("Please enter a one line sentence.");
String text = SavitchIn.readLine();
int length = text.length();
char lastChar;

if (length % 2 == 0)
{
System.out.println("Yes");
}
else
{
System.out.println("No");
}


}
Thats the code I'm working on, so far I have it where if the user enters a sentence and it's even it will output YES and if its odd it will output NO. Thats awesome, but now how would i be able to have if it contains a ? and even then output YES and if it has a ? but is Odd say NO.

I don't know what methode to use for String, to find the character '?'
HELP... again this isn't homework lol, just extra practice for me