求如下 java 代码的输出?? class T implements Cloneable{ public static int k = 0; public static T t1 = new T("t1"); public static T t2 = new T("t2"); public static int i = print("i"); public static int n = 99; public int j = print(&quo…
做个简单笔录,就当是重温下基础知识. 1.先看代码: package com.test; public class Test { public static void main(String[] args) { Son s = new Son(); } } class Parent{ int parent = 10; { System.out.println("parent中的初始化块"); } static{ System.out.println("parent中stati…
结论:对于静态变量.静态初始化块.变量.初始化块.构造器,它们的初始化顺序依次是(静态变量.静态初始化块)>(变量.初始化块)>构造器. public class Test4 { @Test public void test(){ child child = new child(); } } class parent{ public static String parentStaticField = "父类静态变量"; public String parentNormalF…