Assuming that the NPE is occuring at this line (and I think it is)
for (int i=0; i<division.getNumTeams();i++){
it is happening because division
is null
. That is the only possible cause for an NPE to be thrown at that point.
And my reading of your code is that you have not initialized it, so it should be null
.
Note that the code in main
that creates 2 Division
objects does NOT initialize the division
instance variable. Look at the code carefully.