How to construct a Non Instantiable AND Non Inheritable Class in Java
<p>The question says it all.
I know the Singleton pattern (with final to its class) is a solution. Are there any other possible ways we can achieve this? 
Abstracting a class makes it non-instantiable. Making it final makes it non-inheritable.
How do we combine both?</p>

<pre><code>public final class SingletonObject
{
  private SingletonObject()
  {
    // no code req'd
  }

  /*public static SingletonObject getSingletonObject()
  {
    if (ref == null)
        // it's ok, we can call this constructor
        ref = new SingletonObject();        
    return ref;
  }*/

  public Object clone()
    throws CloneNotSupportedException
  {
    throw new CloneNotSupportedException(); 
    // that'll teach 'em
  }

  private static SingletonObject ref;
}
</code></pre>

<p>Code Ref: <a href="http://www.javacoffeebreak.com/articles/designpatterns/index.html" rel="nofollow">http://www.javacoffeebreak.com/articles/designpatterns/index.html</a></p>
