1.先父类,后子类
2.先静态,后非静态
3.先属性,后构造方法
父类静态变量,父类静态代码块
子类静态变量,子类静态代码块
父类非静态变量,父类非静态代码块,父类构造函数
子类非静态变量,子类非静态代码块,子类构造函数
package com.acofkings;
public class Test {
public static void main(String[] args) {
new apple();
}
}
class tree {
private static int treenum = getnum();
private int treenum2 = getnum4();
private int getnum4() {
System.out.println("treenum2 init...");
return 4;
}
private static int getnum()
{
System.out.println("treenum static init...");
return 1;
}
static
{
System.out.println("tree static ");
}
{
System.out.println("tree");
}
public tree() {
System.out.println("tree init...");
}
}
class apple extends tree{
private static int applenum = getnum2();
private int applenum2 =getnum3();
private static int getnum2() {
System.out.println("applenum stati