本帖最后由 刘文飞 于 2012-10-19 11:49 编辑
代码如下:
——————————————————————————————————————————————————
class Person{
private String name;
private int age;
public Person(String name,int age){
this.name = name;
this.age = age;
}
public String getName(){
return this.name;
}
public int getAge(){
return this.age;
}
public String toString(){
System.out.println("Name : " + this.name + "Age : " + this.age);
}
public void finalize() throws Throwable{
System.out.println("Finalize Object : " + this);
}
}
public class SystemDemo02{
Person per = new Person("hezi",82);
per = null; //断开引用
System.gc(); //强制释放空间
}
————————————————————————————————————————————————
错误提示如下:
——————————————————————————————————————————————————
I:\code\java>javac SystemDemo02.java
SystemDemo02.java:23: 需要 <标识符>
per = null; //断开引用
^
SystemDemo02.java:24: 需要 <标识符>
System.gc(); //强制释放空间
^
2 错误
|