javaSE基礎07之代碼塊

1、普通代碼塊

2、構造塊

3、靜態代碼塊(最先調用,且只調用一次)


public class Demo08 {

    /**
     * @param args the command line arguments
     */
    {
        System.out.println("通用代碼塊");
    }
    
    static{
        System.out.println("靜態代碼塊");
    }
    public void Demo08(){
        System.out.println("構造方法一");
    }
    public void Demo08(int a){
         System.out.println("構造方法二");
    }
    public void Demo08(int a,int b){
         System.out.println("構造方法三");
    }
    public static void main(String[] args) {
        // TODO code application logic here
        Demo08 demo=new Demo08();
        demo.Demo08();
        demo.Demo08(1);
        demo.Demo08(1,2);
    }
    
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章