No, really

In support of my earlier claim that Java enums are subclassable, here is an example inspired by McGraw-Hill’s SCJP 6 study guide:

public enum CoffeeSize {
    REGULAR(4), BIG(8), HUGE(12), OVERWHELMING(16) {
        public void drink() { super.drink(); System.out.println("barf"); } };
    private int oz;
    CoffeeSize(int oz) { this.oz = oz; }
    public void drink() { for (int n = 0; n < oz; ++n) System.out.println("glug"); }
    public static void main(String[] args) { CoffeeSize.OVERWHELMING.drink(); }
}

No, silly! It’s an enum!

Ah, to have been a fly on the wall when they designed Java 5. Imagine a meeting between three unnamed Java language designers:

JLD#1: OK, so, new language features for 5, what’s next on our list? Anyone?
JLD#2: There’s always enums.
JLD#3: Not enums again!
JLD#2: Well, they keep asking for it. It’s getting pretty tiresome. Why don’t we just give them enums, and be done with it? How hard can it be?
JLD#1: OK, let’s consider enums for a minute. How do we do that? Continue reading “No, silly! It’s an enum!”

Katzenjammer

Not exactly fresh, but I guess I needed a week or so to recover.

Saturday before last, K and I did something extremely out of character—not only did we go out (which rarely happens), not only did we go to a concert (I think the last time was Suzanne Vega in August of last year), but we went to see a band we’d never even heard of: Katzenjammer.

Continue reading “Katzenjammer”

2,600 years of progress

I just finished The Dreaming Void, the first book in Peter F. Hamilton‘s Void Trilogy. Overall an excellent book, but I do have a nit to pick… a rather big one, in fact.

To provide some background: the Void Trilogy is set in the same continuity as Misspent Youth and the Commonwealth Saga, about 2,500 years after the former, 1,200 years after the latter, and close to 2,600 years after our time. Continue reading “2,600 years of progress”