我在stackoverflow上读过类似的问题,但是他们回答了如何处理(用-Xlint:deprecation
进行编译),而不是为什么错误首先发生。我想知道为什么错误会突然出现第一名。
盒子类
public class box{
int height;
int length;
int breadth;
public int volume(){
return height*length*breadth;
}
box(int h,int l,int b){
height = h;
length = l;
breadth = b;
}
protected void finalize(){
System.out.println("Im dying!!");
}}
测试班
public class test{
public static void main(String[] args){
box a = new box(12,12,12);
System.out.println("The volume is :"+ a.volume());
a = null;
}}
错误:
Note: ./box.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.