Where is the problem? If I use a variable it works just fine, but I am missing something.
public boolean xyzThere(String str) {
if (str.length() > 2){
if(str.startsWith("xyz")){
return true;
} else {
for (int i = 1; i < str.length() - 2; i++){
if(str.substring(i, i + 3).equals("xyz") && !str.substring(i - 1, i).equals(".")) {
return true;
} else {
return false;
}
}
}
} else if(str.length() < 3){
return false;
}
}
Aucun commentaire:
Enregistrer un commentaire