Java错误:找不到symbol Rational()
我只是根据我的导师的喜好使用acm软件包
这个程序应该分配10000个rational对象,使它们成为垃圾,然后计算使用垃圾收集器前后的可用内存。然后,它应该打印垃圾收集器清除的内存量
import acm.program.*;
public class RuntimeGarbage extends ConsoleProgram {
public void run() {
println("Allocating 10000 Rational Objects");
for(int i=1; i==10000; i++) {
new Rational();
}
Runtime myRuntime = Runtime.getRuntime();
long free_before = myRuntime.freeMemory();
myRuntime.gc();
long free_after = myRuntime.freeMemory();
println("Garbage collection freed" + ((free_after)-(free_before)) + "bytes");
}
}
问题是,当我试图编译代码时,cmd会显示以下内容:
:8: error: cannot find symbol
new Rational();
with an arrow right below the R.
问题是在花括号内创建对象吗
共 (0) 个答案