Skip to main content
4 of 4
added 188 characters in body

How about this?

public static String deFront(String str)
{
    String one = (str.length() > 0 && str.charAt(0) == 'a') ? "a" : "";
    String two = (str.length() > 1 && str.charAt(1) == 'b') ? "b" : "";

    return one+two+((str.length() > 2) ? str.substring(2) : "");        
}

Note that only the parentheses around the entire ternary operation in the return are actually necessary, the others are for readability, as per @abuzittingillifirca's suggestion.