Simon Buckle's Weblog

Random thoughts for random people

Archive for March, 2009

Java Puzzler

Comments

Yesterday I read an article of an interview with Joshua Bloch about Java. In the interview he talked about where Java was heading and some of its quirks. Here’s an example of a quirk he gave in the interview:


public class Unbelievable {
    static Integer i;
    public static void main(String[] args) {
            if (i == 42)
                System.out.println("Unbelievable");
    }
}

Fairly innocuous bit of code … so what does it do? Well if you run it you get a NullPointerException, which is no surprise as the variable hasn’t been initialized. What is surprising is why the compiler didn’t pick this up at compile time! For example, if I modify the code to the example below, it doesn’t compile because the variable has not been initialized:


public class Unbelievable {
    public static void main(String[] args) {
            Integer i;
            if (i == 42)
                System.out.println("Unbelievable");
    }
}

Any Java experts out there care to explain this one to me? I compiled the above examples using Java 1.5 on the Mac.

Written by admin

March 16th, 2009 at 8:12 am

Posted in Uncategorized

CNBC Gives Financial Advice

Comments

Written by admin

March 5th, 2009 at 10:33 pm

Posted in Uncategorized

Honda Rescued By?

Comments

According to the BBC, Honda have received financial backing that will allow them to compete next season but – as at the time of writing this – haven’t said from who. Step forward Richard Branson. Why? Well I reckon it would have something to do with Branson’s Virgin Fuels venture and wouldn’t be just a branding exercise. A Formula One car would be a perfect vehicle – in more than one sense of the word – to test high performance fuels etc – assuming they can be competitive of course – and the amount of data they would obtain from the car could increase the rate at which the fuels are developed; it would do no harm at the very least.

There have been rumors over the last couple of weeks about Branson getting involved in F1 so I am not exactly being 100% original in my prediction but then again, I could still be completely wrong!

Written by admin

March 5th, 2009 at 1:01 pm

Posted in Uncategorized