StackOverflow Error at java.util.AbstractColllection.<init>(Unknown Source)
- by thebulge
I fixed my prior problem yesterday by just separating all the classes into separate files. Nevertheless, I wrote all the code down and seeing no errors was able to compile the program. Or so I thought.
Here's the error code:
Exception in thread "main" java.lang.StackOverflowError
at java.util.AbstractCollection.<init>(Unknown Source)
at java.util.AbstractList.<init>(Unknown Source)
at java.util.Vector.<init>(Unknown Source)
at java.util.Vector.<init>(Unknown Source)
at java.util.Vector.<init>(Unknown Source
Here are the spots where my I get the errors(marked with problem?)
public class GameWorld implements IObservable, IGameWorld
{
// create collections class
public Vector<GameObject> GameObjectList = new Vector<GameObject>(); // PROBLEM
private Vector<IObserver> ObserverList = new Vector<IObserver>();
// declare objects
Tank pTank = new Tank(10, 10);
// other objects and variables to declare
public GameWorld()
{
// add objects to GameObjectList
}
// accessors/mutators
}
I get another error here
public class Tank extends Movable implements ISteerable
{
private int armorStrength;
private int missileCount;
public Tank()
{}
public Tank(int armStr, int misslCt) // problem?
{
armorStrength = armStr; // default armorStrength
missileCount = misslCt; // default missileCount
}
public void setDirection(int direction)
{
this.setDirection(direction); // get input from left turn or right turn
// updateValues();
}
// access/mutators here
I'm stumped on what to do here.