001package singleton.state;
002public class S {
003        private S() {}
004        static private SState state;
005        static {
006                if ("linux".equals(System.getProperty("os.name"))) {
007                        state = new SLinux();
008                } else {
009                        state = new SOther();
010                }
011        }
012        static public int inc() { return state.inc(); }
013
014        static private interface SState {
015                public int inc();
016        }
017        static private class SLinux implements SState {
018                private int i;
019                public int inc() {return ++i;}
020        }
021        static private class SOther implements SState {
022                private int i;
023                public int inc() {return --i;}
024        }
025}