我在下面得到一个 nullPointerException 。有人可以解释为什么吗?谢谢!
private SpatialPooler spatialPooler;
private Region region;
private Column column33;
public void setUp()
{
this.spatialPooler = new SpatialPooler();
this.region = new Region(30, 40, 6, 8, 1.0f, 1, 1);
this.column33 = this.region.getColumn(3, 3);
}
public void addActiveColumn(Column activeColumn)
{
this.activeColumns.add(activeColumn); // nullPointerException here!
}
public Column getActiveColumn(int x, int y)
{
for (Column activeColumn : this.activeColumns)
{
if (activeColumn.getX() == x && activeColumn.getY() == y)
{
return activeColumn;
}
}
return null;
}
// in a test class that is in the same package.
public void testGetAndAddActiveColumn()
{
this.spatialPooler.addActiveColumn(this.column33);
assertNull(this.spatialPooler.getActiveColumn(3, 3));
this.column33.setActiveState(true);
assertEquals(this.column33, this.spatialPooler.getActiveColumn(3, 3));
}