This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
because myName is a static member of the class. The fact that java allows you to reference a static member using the instance of the class is simply a syntactic sugar, it doesnot use the instance reference to retrive the value of the member [ August 23, 2006: Message edited by: Neelesh Bodas ]
As we know static variables or static methods can be executed by class name also so The compiler replaces line System.out.println(r1.myName); as System.out.println(returnNull.myName); this is why there is no null point exception. Check the code above