Java入門–abstractクラスのgetInstanceの使い方
Javaコード:
abstract class InstanceDemo{
static int i=8;
public static GetInstanceDemo getInstance(){
System.out.println(i++);
return null;
}
}
public class GetInstanceDemo {
public static void main(String[] args) {
@SuppressWarnings(“unused")
GetInstanceDemo in1=InstanceDemo.getInstance();
@SuppressWarnings(“unused")
GetInstanceDemo in2=InstanceDemo.getInstance();
}
}
実行結果:
8
9