Reputation: 3
import java.lang.Exception;
public class ClassroomTester {
public static void main (String [] agrs)// throws Exception
{
Classroom class = new Classroom(5, "CS102");
}
}
This is the tester class of a Classroom class , but JCreator neither highligths the "Classroom" nor gives an error/exception about not being able to find it. It gives syntax errors such :
error: not a statement , error: ';' expected , error: expected , error: illegal start of type , error: reached end of file while parsing.
The assignment is about throwing exceptions (FileNotFoundException , IOException etc.) and we were supposed to edit the classes (Mostly Classroom ) and test it.
Upvotes: 0
Views: 77
Reputation: 308
It is simple. You can't use "class" as the variable name. It is a reserved keyword. Please change the variable name to some other valid name.
Classroom classRoom = new Classroom(5, "CS102");
Upvotes: 3