SE450: Singleton: Static class [14/32] |
file:S.java [source] [doc-public] [doc-private]
01
02
03
04
05
06
07
package singleton.staticClass; public class S { static private int i; private S() {} static public int inc() { return i++; } }
file:Main.java [source] [doc-public] [doc-private]
01
02
03
04
05
06
07
08
package singleton.staticClass.main; import singleton.staticClass.S; public class Main { public static void main (String[] args) { System.out.println(S.inc()); System.out.println(S.inc()); } }