Tuesday, February 02, 2010

Java Initialization blocks...why should we ever use them?

Coming from a C# world I'm trying to get a grasp on the Java language, mostly for comparison purposes and to see if really the grass is greener on the other side of the fence.

What I like so far of the Java 1.6 that I see C# might benefit from:
1. The main one is cross platform portability. I wish Mono would have more support.
2. Enums are more complex, but I'm wondering if we ever really use that complexity...
3. Static imports, but do they really add to maintainability or make it worse?

What I find confusing in Java vs C#:

1. Checked exceptions: In Java, the exceptions that a method throws must be declared and are part of a method's public interface. They were left out from C# on purpose. Here's an interview made by Bruce Eckel (Thinking in C++) to Anders Hejlsberg (lead C# architect and Turbo Pascal creator, I should point out I wrote my first program in Turbo Pascal :-p)...
2. Initialization blocks, not the static ones that are similar to c# static constructors but instance initialization blocks...why would you ever use them? I'm still puzzled...


Post a Comment

<< Home