Hi, here i Have written a class "vObject"which has two public fields Name and Salary. In another class i m creating an Array object of this class,, and trying to set values but at runtime its giving Null pointer Exception can anyone tell me why its like that or whats the solution.
Here in second class on runtime its throwing Null Pointer Exception?? [ edited to help preserve formatting of code with the [code and ]/code UBB tags -ds ] [ December 28, 2003: Message edited by: Dirk Schreckmann ]
Actually that's the only way to do this. You can't use an object that doesn't exist, so the object must be created. Why are you concerned about efficiency? According to some of the JVM writers at JavaOne, object creation has been designed to be very efficient and fast in Java. Donald Knuth is quoted as saying something akin to "Premature optimization is the root of all evil." I'd suggest that your concern for efficiency is ill-placed.