Page 1 of 1

Create instances for classes

Posted: Tue Jan 17, 2017 5:23 am
by leogen
I have separate packages in my project and I need to create instances for all classes in this packages. I create instance of class by the below code.
But I have problem with deleting my packages and applet after I call Digest.getInstance(). I need to implement clearInstacePool() method to set reference of digest to null in unistall() method of my applet. How can I create instance of class without implementing clearInstacePool()?

Code: Select all

public class Digest 
{
   private static Digest digest = null;
   protected Digest ()
  {
 
  }
  public static Digest getInstance()
  {
         if(digest == null)
          digest = new Digest();
         
        return digest;
  }
  public static void clearInstacePool()
  {
         digest = null;
  }
}

Re: Create instances for classes

Posted: Tue Jan 17, 2017 10:52 pm
by mabel
Create instance usually involves the new operator, which has nothing to do with what methods are implemented.