This is what I wrote for a coding bat project thing. For some reason it says that this way it doesn't work but if I flip it, it works. Why is that? When it inputs something with less than 3 chars it gets an error message according to codingbat.
// Given a string, return a new string where "not " has been added to the front. 
// However, if the string already begins with "not", return the string unchanged. 
// Note: use .equals() to compare 2 strings. 
// notString("candy") → "not candy"
// notString("x") → "not x"
// notString("not bad") → "not bad"
        public String notString(String str) {
                  String m;
          if ( str.substring (0,3).equalsIgnoreCase("not") && str.length () >= 3 ) // this line doesn't work in it's current state 
          // but works if I flip the two boolean expressions over the &&
                    m = str;
          else {
                    m = "not " + str;
                }
       return m;
 
     
     
     
     
    