Here is a puzzle form his blog:
cOoKiEs PuZzLe
If cookies were Strings, could you write the Cookie Monster? The class Count is given:
package count;
import monster.CookieMonster;
public class Count {
public static void main(
String[] args) {
String noCookie = CookieMonster.eat("cookie");
if (noCookie.isEmpty() && CookieMonster.eat(noCookie).length() < noCookie.length()) {
// The goal is to reach this line
System.out.println("Minus one cookie!");
}
}
}
Edit the Cookie Monster to make it work:
package monster;
public class CookieMonster {
public static String eat(String cookie) {
return cookie.substring(0, cookie.length() - 6);
}
}
-------------------------------
Spring AOP and custom class loaders seem like cheating to me. I wonder how you can do this with
Java SE only.