> maybe even better stil:
>
> public class MySingleton {
>          /*
>           * The only instance of the editor - a Singleton
>           */
>          private static final MySingleton instance= new MySingleton();
>
> add the final keyword for java optimalisation. You even get a warning when
> you try to create a second singleton.
>
> Hugo
>
>
>
> ----- Original Message -----
> From: "Erik Beijnoff" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, September 17, 2003 8:33 AM
> Subject: Re: Singleton Object.
>
>
> > >How do I create singleton object in Java? Can you give some examples on
> > that.
> >
> > It is quite simple. This is a standard singleton pattern.
> >
> > --------------------------------------------------------------
> > public class MySingleton {
> >         /*
> >          * The only instance of the editor - a Singleton
> >          */
> >         private static MySingleton instance= new MySingleton();
> >
> >         /*
> >          * Constructor - hidden
> >          */
> >         private MySingleton() {
> >         }
> >
> >         /*
> >          * Main entrance point to get a hold of the instance
> >          */
> >         public static MySingleton getInstance() {
> >                 return instance;
> >         }
> >
> >         /*
> >          * Method to do work
> >          */
> >         public void doSomething() {
> >         }
> > }
> > ---------------------------------------------------------------
> > Erik Beijnoff
> > Addsystems
> >
> > [EMAIL PROTECTED]
> > [EMAIL PROTECTED]
> >
> >
>
===========================================================================
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> > For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> DIGEST".
> >
> > Some relevant archives, FAQs and Forums on JSPs can be found at:
> >
> >  http://java.sun.com/products/jsp
> >  http://archives.java.sun.com/jsp-interest.html
> >  http://forums.java.sun.com
> >  http://www.jspinsider.com
> >
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
>
> Some relevant archives, FAQs and Forums on JSPs can be found at:
>
>  http://java.sun.com/products/jsp
>  http://archives.java.sun.com/jsp-interest.html
>  http://forums.java.sun.com
>  http://www.jspinsider.com
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".

Some relevant archives, FAQs and Forums on JSPs can be found at:

 http://java.sun.com/products/jsp
 http://archives.java.sun.com/jsp-interest.html
 http://forums.java.sun.com
 http://www.jspinsider.com

Reply via email to