Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!

BalajiS Sridharan

Greenhorn
+ Follow
since Aug 29, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by BalajiS Sridharan

make the constructor private and have a public static method which will instantiate a instance but before instantiating check whether the variable is null or not

e.g.

public class SingleInstance
{
private SingleInstance()
{


}

private singleInstance;


public static SingleInstance returnSingleInstance()
{
if(singleInstance == null)
{
singleInstance = new SingleInstance();
}
return singleInstance;

}
}
[ September 05, 2005: Message edited by: BalajiS Sridharan ]
15 years ago
A class is basically a blueprint which u can use..., consider a class as a factory that will provide u with as many number of the blueprint as u need (which are called as objects)..., creating a object from a class is called instantiation.

U can instantiate a class by using the keyword new.
15 years ago