This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
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 Java Interview Guide this week in the Jobs Discussion 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
It's not a secret anymore!