「Java入門」staticメソッドのサンプル

class Simple {
static int a;
int b;
}

Simple cftA = new Simple();
Simple cftB = new Simple();
cftA.a = 1;
cftA.b = 2;
cftB.a = 3;
cftB.b = 4;
System.out.println(cftA.a + cftA.b + cftB.a + cftB.b);

結果
3234

Comments are closed.