What I would like to happen:
public Predator() { System.out.println("Say hello to " + this); } public ~Predator() { System.out.println("Someone killed " + this); }
What I have to do in Java:
public Predator() { System.out.println("Say hello to " + this); } public void finalize() { System.out.println("Someone killed " + this); }
and if I'm wearing my lucky rabbit's foot, the moon is blue, and a black cat is following me, then finalize() might just get called when the Predator gets killed. In fact I'm lucky (it seems) if finalize() gets called at all. Hmm. So much for my bright idea for debugging.
In case you're wondering, pet peeves #1 and #2 in Java are the inability to switch() on a String, and the lack of enums in any sane form.