public boolean hasBad(String str) { if (str.startsWith("bad")) { return true; } else if (str.startsWith("bad",1)) { // alternate version of startsWith() !!! return true; } else { return false; } } public boolean hasBad1(String str) { if (str.startsWith("bad")) { return true; } else if (!str.isEmpty()) { return str.substring(1).startsWith("bad"); } else { return false; } } public boolean hasBad2(String str) { if (str.startsWith("bad")) { return true; } else { return !str.isEmpty() && str.substring(1).startsWith("bad"); } } public boolean hasBad3(String str) { return str.startsWith("bad") || ( !str.isEmpty() && str.substring(1).startsWith("bad") ); }