null pointer exception
I am catching #@#%$ with this runtime null pointer exception. I know where it is but for some reason, I can't get rid of it no matter what i do. Help!!!
here is my entire code:
import java.util.*;
import java.io.*;
publicclass Tubeimplements Energy{
public Sequence[] seqArray =new Sequence[2];
public Sequence[] aStrand =new Sequence[20];
public Sequence test=new Sequence();
publicint numSeq = 0;
publicint testLength = 0;
publicint number =0;
publicint length = 0;
public Random generator =new Random();
public String[] gene ={"A","C","G","T"};
int d = 0;
/** Adds a sequence and copies it with doubleArray() */
publicvoid addSequence(Sequence A){
if(numSeq >= seqArray.length)
seqArray = doubleArray();
seqArray[numSeq++] = A;
}
/** Sets a TestLength */
publicvoid setTestLength(int i){
this.testLength = i;
}
/** Gets the sequence Array */
public Sequence[] getSeqArray(){
return this.seqArray;
}
/** Gets the number of the sequence */
publicint getNumSeq(){
return this.numSeq;
}
/** Tests to see if sequences are the same */
publicboolean isDuplex(Sequence A, Sequence B){
int iter = A.getSequence().length() - this.testLength + 1;
String testWMer;
String Astring = A.getSequence();
String Bstring = B.getSequence();
for(int i = 0; i < iter; i++){
testWMer = Astring.substring(i, i + this.testLength);
if(Bstring.indexOf(testWMer) != -1)
returntrue;
}
returnfalse;
}
/** copies array */
private Sequence[] doubleArray(){
Sequence[] newArray =new Sequence[2*this.seqArray.length];
System.arraycopy(this.seqArray, 0, newArray, 0, numSeq);
return newArray;
}
/** creates random sequences */
public Sequence[] randomSequence(int number,int length)
{
Random generator =new Random();
test.sequence ="";
for(int i = 0; i < number; i++){// number of sequences to be made
aStrand[i].sequence = test.sequence;// <--here is where i get the null pointer exception
for(int j = 0; j < length; j++){//length of sequences to be made;
int d = generator.nextInt(4);
aStrand[i].sequence += gene[d];
}
aStrand[i].sequence += gene[d];
}
return aStrand;
}
}

