This problem is starting to drive me insane. I'm sure it must be something really simple, but I just can't seem to find out where the problem is. I initialize a population from the main() function, containing a collection of individuals with:
I then try to access the attributes of one of those Individuals to test if the program works with:
But it does not work, the compiler throws a null pointer exception. Any help anyone can provide will be gratefully accepted.
In your Population class you're creating an Individual array, but you aren't putting anything in it. When an array of some sort of object is created it just contains nulls everywhere. So when you call robots.getPositionX() ...robots is null.
You need to create the Individual objects and put them in the array.