-
public Boolean parameterIsAQuestion( String text ) {
Integer positionOfLastChar = text.length() - 1;
if ( text.charAt( positionOfLastChar ) == '?' ) {
return true;
}
return false;
}
- There are several different ways to solve this problem; one solution would be:
public Boolean parameterContainsAnInternalSpace( String text ) {
String middlePart = text.substring(1, text.length()-1 );
if ( middlePart.indexOf(" ") >= 0 ) {
return true;
}
return false;
}
You could also use the contains
method in combination with the substring
and/or charAt
methods to solve this problem.
-
70
p
Apr
many flowers this year!
28
53
6