package rubbishdemo;public class finalizedemo {
public static void main(String[] args) {
Book novel=new Book(true);
novel.checkInt();
new Book(true);
System.gc();
}
}
class Book{
boolean checkedOut=false;
Book(boolean checkOut){
checkedOut=checkOut;
}
void checkInt(){
checkedOut=false;
}
protected void finalize(){
if(checkedOut){
System.out.println("Error :checked out");
}
}
}System.gc();
这句话 是什么意思啊
public static void main(String[] args) {
Book novel=new Book(true);
novel.checkInt();
new Book(true);
System.gc();
}
}
class Book{
boolean checkedOut=false;
Book(boolean checkOut){
checkedOut=checkOut;
}
void checkInt(){
checkedOut=false;
}
protected void finalize(){
if(checkedOut){
System.out.println("Error :checked out");
}
}
}System.gc();
这句话 是什么意思啊
垃圾回收、
处理数据量大的时候,适时的调用下 System.gc() ,提高下性能,也避免出现 out of memory