Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need Help with ArrayList - NullPointerException

 
achana chan
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?!?
 
Arnold Reuser
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
achana chan
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all, for giving me your time and your assistance.
It was very much appreciated.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic