This post originated from an RSS feed registered with Java Buzz
by Joe Shelby.
Original Post: Don't reference statics through instances. Period.
Feed Title: Joe's Java Jottings
Feed URL: http://www.blog-city.com/bc/
Feed Description: Notes, observations, and occasional other stuff on Java, with concentrations on Swing, XML, and the Semantic (Object) Web.
DavidFlanagan.com:The following program does not throw a NullPointerException
public class StaticFieldThroughNull {
public static void main(String[] args) {
Double d = null;
System.out.println(d.MAX_VALUE);
}
}
This really is supposed to work this way.
This is one of those cases where the IDEs have worked pretty hard to make up for shortcomings in the Java compiler. Eclipse will flag that with a