2009-06-19

More puzzling behaviour

Still in the spirit of Java Puzzlers; can you provide declarations for i and j to make this statement fail at runtime?

i = j;


I spent quite some time debugging this, once...

Puzzling behaviour

In the spirit of Java Puzzlers, what does this program print (if anything)?

public class java
{
static lang lang = new lang();

static class lang
{
static Long Short = new Long();

static class Short
{
}

static class Long
extends Short
{
}
}

public static void main(String[] args) {
System.out.println(java.lang.Short.class.getSimpleName());
}
}