1.例9.3
析构函数
public class Cjava { public static void main(String[]args) { Student s1=new Student(10010,"qi xi",'f'); s1.display(); Student s2=new Student(10011,"mi xi",'m'); s2.display(); s1.finalize(); s2.finalize(); } } class Student{ int num;char sex;String name; Student(int n,String na,char s){ num=n;name=na;sex=s; System.out.println("Constructor called"); } protected void finalize() { System.out.println("Dextructor called"); } void display() { System.out.println("num"+num+"name:"+name+"sex:"+sex); } }
2.没问题
3.明天继续写例题