<< September 25, 2008 | Home | September 27, 2008 >>

Neal Gafter To Join Microsoft

(Via Twitter.)

Neal Gafter: Joined the JavaPosse last night for a new minutes during their recording session, discussing my new employer... Microsoft.
Danny Lagrouw: @gafter huh? Microsoft? But c# already has closures!
Neal Gafter: @danny_l Doh!

But, but, but,...

Friday Java Quiz: Enhanced for Loop

Q: Will the following program compile? Run without exceptions? If so, what will it print?

public class Foo {
  public static void main(String[] args) {
    String[][] sss = new String[2][];
    int c = 0;
    for (String[] ss: sss) {
      ss = new String[3];
      for (String s: ss) {
        s = "Slot # " + c++;
      }
    }
    for (String[] ss: sss) {
      for (String s: ss) {
        System.out.println(s);
      }
    }
  }
}

Strict rules this week: you must not actually compile the program before answering the questions.

Tags :