class Insec{
    private int i = 9;
    protected int j;
    Insec(){
        System.out.println("i = " + i + ", " + "j = " + j);
        j = 39;
    }
    private static int x1 = printInt("static Insec.x1 init");
    static int printInt(String s){
        System.out.println(s);
        return 47;
    }
    private int k = printInt("Insec init k");
}
public class Garbage extends Insec{
 
    private int k = printInt("beetle.k init");
 
    public Garbage(){
        System.out.println("k = " + k);
        System.out.println("j = " + j);
    }
    public int q = printInt("beetle.q init");
    private static int x2 = printInt("static beetle.x2 init");
     
    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        System.out.println("beetle construct");
        Garbage b = new Garbage();
    }
}

输出:

static Insec.x1 init
static beetle.x2 init
beetle construct
Insec init k
i = 9, j = 0
beetle.k init
beetle.q init
k = 47
j = 39

  

 

相关文章:

  • 2022-12-23
  • 2021-12-31
  • 2022-02-07
  • 2021-07-02
  • 2022-12-23
  • 2021-12-22
  • 2021-10-16
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-06
  • 2021-12-29
  • 2022-12-23
  • 2022-12-23
  • 2022-01-21
  • 2021-06-06
相关资源
相似解决方案