鲜荣彬
Herry
摘要: 最近,看到一道面试题,如下class Class1{ private static int count = 0; static Class1() { count++; } public Class1() { count++; }} Class1 one = new Class1(); Class1 two = new Class1(); 问程序执行完成以后,Class1.Count的值是多少。很显然,考查的是对static关键字的基本认识,答案是3。 从程序的执行顺序来说,第一次实例化类Class1时,先走静态构造函... 阅读全文
posted @ 2013-12-06 09:51 Herry彬 阅读(6716) 评论(3) 推荐(0)