File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Null Pointer Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Null Pointer Exception" Watch "Null Pointer Exception" New topic

Null Pointer Exception

Corbin Blake

Joined: Nov 10, 2004
Posts: 22
Can anybody tell me how i can get rid of a null pointer exception, that happens in a runtime error.

Here are all my variables for the entire class:

here is my code

I hope you know your paying me for this!
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
Based on the code you showed, you never put a reference to a Sequence object into aStrand[i], so you can't modify the instance variable "sequence" of a nonexistant object. In short, aStrand contains 20 references to null.
[ November 13, 2004: Message edited by: Mike Gershman ]

Mike Gershman
SCJP 1.4, SCWCD in process
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
Try adding this after the declaration of aStrand:
I agree. Here's the link:
subject: Null Pointer Exception