這段代碼在if行報錯"cannot make a static reference to a non-static field tel"是怎么回事?
public class Test2 {
Telphone tel=new Telphone();
Telphone tell=new Telphone();
public static void main(String args[]){
if(tel.equals(tell)){
System.out.println("兩個對象是相同的");
}else{
System.out.println("兩個對象是不同的");
}
}
}
2015-07-09
創(chuàng)建對象的引用時,是放在方法內(nèi)部的,而你放在了方法的外部
2015-06-11
為什么一定編譯器要我把tel和tell對象加上static修飾符。