Are you sure it was like that? Although code blocks can be defined like that, it doesn't do much, except limiting the scope of local variables, which isn't exciting.
However, class-level anonymous code blocks are useful to initialise variables, and populate data structures, etc.
For example, this static anonymous block initialises a final static variable.
public class Snippet {
private final static Map config;
static {
HashMap tmp = new HashMap();
tmp.put("moo","foo");
tmp.put("bar","baz");
config = Collections.unmodifiableMap(tmp);
}
// rest of class here.
}
It works int the same way for non-static blocks and instance variables, which is less useful, but handy if you want to make sure that all constructors and subclasses executes the same code.
I found this thread, which is not a duplicate, but related.
Anonymous code blocks in Java