This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
As far as the code is concerned it does throw an ArrayIndexOutOfBoundsException but as you placed it inside the initializer the exception is thrown when an object of this class is created/instantiated. Try writing new A() in main() method to check it out.
Going back to your first question:
Raju Champaklal wrote:
int a=new int;
does this mean that
a=null; and so on till a ? i think this is why i get null pointer exception when i try to sue a;
This is an array of arrays so the cells you refer to by the first dimension are actually references to the second array so they indeed are initialized to contain null values. This also implies that you cannot refer to a since there isn't anything initialized there which results in NullPointerException.
Joined: Dec 10, 2009
oh yes...i got that error...i was actually expecting to get Exceptionininitializererror...when this exception thrown?
Joined: Feb 16, 2008
Raju Champaklal wrote:oh yes...i got that error...i was actually expecting to get Exceptionininitializererror...when this exception thrown?
ExceptionInInitializerError is thrown when something goes wrong within static initialization block while your exception was thrown in instance initializer. You can obtain it by simply reimplementing your class as follows:
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com