/* You can use Apache Commons */ StringUtils.isEmpty(str) /* which checks for empty strings and handles null gracefully. */ /* HINT */ /* the shorter and simler your code, the easier it is to test it */