Java- 클래스 실행 순서(이미지 프로그래밍 생각용)

1621 단어
하나의 클래스를 초기화하려면 먼저 그것의 속성을 초기화하고 하나의 클래스 대상을 구성해야 하며, 반드시 먼저 그것의 부류 대상을 구성해야 한다.슈퍼 ()에 대한 호출은 구조 방법의 첫 번째 문장이어야 합니다.
package mianxaingduixaing;
/* * ( ), ( ) *  ,  *  (new )  *  (new ) ,  */
public class test {
    public static void main(String[] args) {
        father f=new child();
        f=new child();
    }
}
class father{
    public father(){
        System.out.println("father.....");
    }
    static{// 
        System.out.println("father2......");
    }
}
class child extends father{
    public child(){
        System.out.println("child.....");
    }
    static{
        System.out.println("child2......");
    }
}

좋은 웹페이지 즐겨찾기