In a Java assignment I am required to use the throw Exception, but I get a weird error:
Controller.java:13: error: ';' expected
public Controller() throw Exception { ^
The code follows:
import java.awt.*;
import java.lang.*;
public class Controller {
private Canvas can;
private Arrow arr;
public static void main(String[] args){
new Controller();
}
public Controller() throws Exception {
can = new Canvas("Animation", 300, 700);
arr = new Arrow(can);
arr.draw();
Thread.currentThread().sleep(100);
for (int i = 1; i <= 10; i++){
arr.erase();
arr.moveUp();
arr.draw();
Thread.currentThread().sleep(100);
}
}
}
The entire syntax seems to be correct, most errors of this type on Stackoverflow are a result of typos, but I don't seem to have any. I edited the smaller mistakes in the code, but I still get the error on the constructor.