类的初始化顺序
程序员文章站
2022-05-23 22:17:20
...
public class Test1 { public static int k = 0; public static Test1 t1 = new Test1("t1"); public static Test1 t2 = new Test1("t2"); public static int i = print("i"); public static int n = 99; public int j = print("j"); { print("构造块"); } static { print("静态块"); } public Test1(String str) { System.out.println((++k) + ":" + str + " i=" + i + " n=" + n); ++i; ++n; } public static int print(String str) { System.out.println((++k) + ":" + str + " i=" + i + " n=" + n); ++n; return ++i; } public static void main(String[] args) { Test1 t = new Test1("init"); } }
上一篇: php请教
下一篇: Yii 动作方法技巧
推荐阅读
-
php中类继承与接口继承的区别是什么
-
第七节--类的静态成员
-
深入理解php中require/include的顺序
-
背水一战 Windows 10 (73) - 控件(控件基类): UIElement - 拖放的基本应用, 手动开启 UIElement 的拖放操作
-
php中抽象类在其方法中例化其子类来完成对自己方法的调用
-
php的MySQL连接类你知道多少?
-
用vbs实现按创建日期的顺序列出一个文件夹中的所有文件
-
PHP中使用Memache作为进程锁的操作类分享,phpmemache_PHP教程
-
memcache 批量获取memcache值并按key的顺序返回的实现代码
-
PHP类的自动载入机制