I have a Cage class:
public class Cage<T extends Animal> {
Cage(int capacity) throws CageException {
if (capacity > 0) {
this.capacity = capacity;
this.arrayOfAnimals = (T[]) new Animal[capacity];
}
else {
throw new CageException("Cage capacity must be integer greater than zero");
}
}
}
I am trying to instantiate an object of Cage in another class main method:
private Cage<Animal> animalCage = new Cage<Animal>(4);
I get the error: "Default constructor cannot handle exception type CageException thrown by implicit super constructor. Must define an explicit constructor." Any ideas? :o(