dimanche 6 août 2017

How to convert a java class to singleton?

public class Singleton {


public Serialize(Object object, String filename) throws IOException
{
FileOutputStream out=new FileOutputStream(filename, true);
ObjectOutputStream oos=new ObjectOutputStream(out);
oos.writeObject(object);
out.close();
}

}

I have created this java class for project. I want to recode this class accorfing to singleton design pattern. Can somebody tell me how to do it? as far as i know it should be a private right? and what should be the different?

Aucun commentaire:

Enregistrer un commentaire