First, a singleton class has only one instance. That can be achieved by
providing only a private constructor, and accessing the only class instance
using a static method which will return a static member initialized by the
private constructor. The static private variable will be initialized only
once. See example:
public class testSingleton {
/* this for test only */
private int instances = 0;
private static testSingleton instance = new testSingleton();
private testSingleton() {
/* it will be incermented one time only */
instances++;
/* some initialization stuff */
}
public static testSingleton getInstance () {
System.out.println("Number of instances :" + instances);
return instance;
}
/* other class stuff */
}
-----------------------------------------------------
Cristian Saceanu
WebQuote.com Inc.
[EMAIL PROTECTED]
-----Original Message-----
From: Ram Mohan <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Date: Friday, March 24, 2000 11:45 AM
Subject: Singleton Class
>Hi All,
>
>Any body know about singleton class ? pl... Just explain some thing
regarding this.
>
>Thanx,
>Ram
>
>--
>
>On Sat, 13 Jan 2001 10:48:34 sachin zingade wrote:
>>RE: Weblogic.propertieswe have downloaded and installed the weblogic we
are able to run the examples.
>>I want some business applications to run and see how to design my project.
>>If any one know any demo application on any site. Please send the URL.
>>
>>thanks in advance.
>>
>>R.Narayana
>>Sachin
>>
>
>
>MailCity. Secure Email Anywhere, Anytime!
>http://www.mailcity.lycos.com
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html