Create the class in a Singleton design pattern. See the "OO, Patterns, UML and Refactoring" group for more details. Basically you will be using a method called instance() to retrieve the instance. if the instance already exists, you will return it, else you will create a new one. There will be a static varaible in the class that will hold the reference to this instance. Initially it is null. Something like the following code.
Hope this helps -Dale ------------------ What's this H2SO4 doing in my fridge?? ( thud ) [This message has been edited by Dale DeMott (edited June 14, 2001).]
By failing to prepare, you are preparing to fail.<br />Benjamin Franklin (1706 - 1790)
Remember to make the instance() method synchronized, else there might be a possibility you end up with more than 1 instance of the object. Another way is just make the instance() method return the _instance object, and during declare _instance with:
Most of the VM will do lazy instantiation of that object anyway.
You don't create 2 instance, you just declared i as static. In this case it doesn't matter how many instance you'll create. Change i from static to non-static and you'll see same result which means we've created only one instance of the class. Have a nice day.