クラス変数とインスタンス変数

public class Sample {

    static int      x = 0;
    int             y = 0;

    public static void main(String[] args) {
        x = 100;
        Sample sample1 = new Sample();
        sample1.y = 200;

        Sample sample2 = new Sample();
        sample2.y = 300;
        sample2.y = 400;
        sample1.y = 500;
        sample2.y = 600;
    }
}
プログラム実行開始前
     

Top Page
更新日:2010-07-01