本帖最后由 yp324 于 2013-5-5 22:27 编辑
class Price{
final static Price INSTANCE = new Price(2.8);
static double initPrice = 20;
double currentPrice;
public Price(double discount){
currentPrice = initPrice-discount;
}
}
class PriceTest{
public static void main(String arg[]){
System.out.println(Price.INSTANCE.currentPrice);
Price p = new Price(2.8);
System.out.println(p.currentPrice);
}
}
运行结果为什么不是两个17.2,求解释
|
|