File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Need Help with ArrayList - NullPointerException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Need Help with ArrayList - NullPointerException " Watch "Need Help with ArrayList - NullPointerException " New topic
Author

Need Help with ArrayList - NullPointerException

achana chan
Ranch Hand

Joined: Jul 29, 2002
Posts: 277
I refer to this thread
http://www.coderanch.com/t/395679/java/java/ArrayList-still-getting-null-pointer
I've modified the code about fiftieth times today and still am stuck with NullPointerException at runtime:

I just cannot get pass this bit of code... What is it, for sanity's sake ?!?


humanum errare est.
Arnold Reuser
Ranch Hand

Joined: Nov 20, 2003
Posts: 196
use
public TXRecord() {
....
}
instead of
public void init() {
....
}
Try reading one of the great java-books of bruce eckel. You can download it from http://64.78.49.204/ I've read it several years ago and still like it.
achana chan
Ranch Hand

Joined: Jul 29, 2002
Posts: 277
Arrgh, looking at the wrong place, misled by the line number for the NullPointerException.
Yes it works like that.
But I don't want the applet to know anything about the indexing in TXRecord, ideally it assigns values to the variables var_<name>

On the receiving end, we now have this code:

The console output looks like this
achana chan
Ranch Hand

Joined: Jul 29, 2002
Posts: 277
the console output looks like this:

system datetime stamp: Feb 25, 2004 7:43:57 PM
ConfirmationFrame: 0
var_acctName: null
var_unitCost: null
Chandra Bairi
Ranch Hand

Joined: Sep 12, 2003
Posts: 152
Whatever values you are assigning to the String arrays that is done in the init() function but that function is never called from the TxnRecord() constructor. then how can the values be assigned . you have to call the init() function at the end of the constructor and probably you will get the desired results.
Thanks
Shekar.


Thanks,
Shekar
achana chan
Ranch Hand

Joined: Jul 29, 2002
Posts: 277
Thanks all, for giving me your time and your assistance.
It was very much appreciated.
 
GeeCON Prague 2014
 
subject: Need Help with ArrayList - NullPointerException