zoukankan      html  css  js  c++  java
  • Java类的成员函数调用顺序

     1 class A
     2 {
     3  public A()
     4  {
     5   System.out.println("----------A 构造-------------");
     6  }
     7  static  void sb()
     8  {
     9   System.out.println("----------A.sb() 静态块-------------");
    10  }
    11  {
    12   System.out.println("----------A 语句块-------------");
    13  }
    14 }
    15 
    16 class B extends A
    17 {
    18  public B()
    19  {
    20   System.out.println("----------B 构造-------------");
    21  }
    22  static void sb()
    23  {
    24   System.out.println("----------B.sb() 静态块-------------");
    25  }
    26  {
    27   System.out.println("----------B 语句块-------------");
    28  }
    29 }
    30 
    31 public class initSequence 
    32 {
    33  public static void main(String[] args)
    34  {
    35   System.out.println("First time new: ");
    36   B b=new B();
    37   System.out.println("Second time new: ");
    38   B b1=new B();
    39   System.out.println("Call the static functions:");
    40   A.sb();
    41   b.sb();
    42  }
    43 }

    输出:

    First time new:
    ----------A 语句块-------------
    ----------A 构造-------------
    ----------B 语句块-------------
    ----------B 构造-------------
    Second time new:
    ----------A 语句块-------------
    ----------A 构造-------------
    ----------B 语句块-------------
    ----------B 构造-------------
    Call the static functions:
    ----------A.sb() 静态块-------------
    ----------B.sb() 静态块-------------
  • 相关阅读:
    LOL 战斗力查询
    D3js-对柱状图的增,删,排序
    我的项目7 js 实现歌词同步(额,小小的效果)
    为什么电脑启动任务管理器会这样
    OpenCV求取轮廓线
    leetcode-Reverse Words in a String
    Linux lvs DR配置
    p2p网贷3种运营模式
    T4308 数据结构判断
    1080 线段树练习
  • 原文地址:https://www.cnblogs.com/dracohan/p/4179475.html
Copyright © 2011-2022 走看看