java静态成员的初始化过程
public class Price{ final static Price INSTANCE = new Price(2.8); static double initPrice = 20; double currentPrice; public Price(double discount){ currentPrice = initPrice - discount; } }
public class Main { public static void main(String[] args) { System.out.println(Price.INSTANCE.currentPrice); Price p = new Price(2.8); System.out.println(p.currentPrice); } }
爱书网:www.2ibook.com 一个优秀的视频教学网站,大学各专业的名师课程。免费,免费,免费。
QQ群:762080163
QQ群:762080163