Java 類的加載

package com.cwcec.p2;

class C
{
    public static final int SIZE;
    static
    {
        SIZE = 100;
        System.out.println("A static...");
    }
}

class Instrument
{
    public Instrument()
    {
        System.out.println("Instrument construction...");
    }
}

public class Wind
{
    public static String S;
    static
    {
        S = "abc";
        System.out.println(S);
    }
    public static void main(String[] args) 
    {
        
        Instrument instrument = new Instrument();
        int t = C.SIZE;
        System.out.println("Wind " + t);
    }
}

輸出結果:spa

abc
Instrument construction...
A static...
Wind 100code

相關文章
相關標籤/搜索