简体   繁体   English

Java找不到我的课

[英]Java can not find my class

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. 这是Classroom类的测试器类,但JCreator既不会高调“ Classroom”,也不会给出有关无法找到它的错误/异常。 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. 分配是关于抛出异常(FileNotFoundException,IOException等)的,我们应该编辑类(Mostly Classroom)并对其进行测试。

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");    

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM