Singleton:
public class Singleton
{
private static Singleton theInstance = null;
private Singleton() {}
public static Singleton Instance()
{
if (theInstance == null) theInstance = new Singleton();
return theInstance;
}
}
Monostate:
public class Monostate
{
private static int itsX = 0;
public Monostate() {}
public void setX(int x) { itsX = x; }
public int getX() { return itsX; }
}