I have two classes in one package in JAVA.
One class in which I have a constructor, an exception that I tried to create myself:
public class ZooException extends Exception { public ZooException(String error) { super(error); } }
Another class should throw this exception at one point:
public class Zoo<T extends Animal> Zoo(int capacity) { if (capacity <= 1) { throw new ZooException("Zoo capacity must be larger than zero"); } }
I notice two things here.
- In the ZooException class, I get a warning: "The CageException serializable class does not declare a static final field serialVersionUID of type long"
- In the Zoo class, in the line starting with "throw new", I get a compilation error: "Unhandled exception type CageException"
Any ideas on what I can do to solve this error in the Zoo class? Thank you in advance!
source share