001package singleton.pub; 002public interface S { 003 public static final S instance = 004 ("linux".equals(System.getProperty("os.name"))) ? new SLinux() : new SOther(); 005 public int inc(); 006} 007final class SLinux implements S { 008 private int i; 009 public int inc() {return ++i;} 010} 011final class SOther implements S { 012 private int i; 013 public int inc() {return --i;} 014}