## Problem:

Given a string, return true if "bad" appears starting at index 0 or 1 in the string, such as with "badxxx" or "xbadxx" but not "xxbadxx". The string may be any length, including 0. Note: use .equals() to compare 2 strings.

## Solution:

public boolean hasBad(String str) {
if(str.length() < 3)
return false;
return true;
else if (str.length() > 3){
return true;
}
return false;
}

1. public boolean hasBad(String str) {

return false;
}
return true;
}
return false;
}

if (str.length() < 3) {
return false;
}

return true;
}

if ( str.length() > 3 && str.substring(1, 4).equals(badStr)) {
return true;
} else {
return false;
}
}

3. public boolean hasBad(String str) {
||
}

4. public boolean hasBad(String str) {
if(str.length()<3) {
return false;
}
return true;
}
return false;
}

5. public final boolean hasBad(String str) {
}

6. public boolean hasBad(String str) {
return ((str.length() >= 3 && str.startsWith("bad"))
|| (str.length() >= 4 && str.substring(1, 4).equals("bad")));
}