While using random generator i get error with message
Exception in thread "main" java.lang.NullPointerException
i completely don't know why, because a lot of time it working, and then it throw exception. I have feeling like resource of generating doubles just has been exploited. I have a lot of messages on screen "psst" (pMutationChangePc is set to 0.0), and accidently it always finishing in error in first IF statement. Do you guys have some ideas how to resolve this problem, or what could be the problem? Code isn't even hard to read some checking values and printing on screen...
public void Mutation()
{
Random r= new Random();
if (r.nextDouble()<mutation.pMutationChangeStrategy && mutation.pMutationChangeStrategy!=0.0)
{
char [] tab= {'P','C','D','K'};
System.out.println("psst");
this.strategy.buffor=MutationRecurtion(tab, r);
}
if (r.nextDouble()<mutation.pMutationChangePc)
{
System.out.println("Mutation");
if (r.nextBoolean()==true)
{
System.out.println("boolean");
this.pOfCoopMax+=mutation.parameterIncMutation;
this.pOfCoopMin+=mutation.parameterIncMutation;
}
else
{
this.pOfCoopMax-=mutation.parameterIncMutation;
this.pOfCoopMin-=mutation.parameterIncMutation;
}
}
}