Post a Job  |   Ask a Question?   |   Already registered? login or register
Bikash Nayak
03/05/2016 04:38 PM

Why should i make a class as singleton?

why should i make a class as singleton..?I know the answer but m not 100% confident,so plz explain it..
Spam    4 Comments

04/05/2016 00:31:05
if you are using a class which does not have instance variable and have final variables. this class also have parameterized methods which values can be passed at runtime, then we can make this class as singleton bcoz it will be used again and again and no need to create object of this again and again. it will save jvm memory.

04/05/2016 15:13:33
1. if a class does not contain any attribute but it contain the member method and the member method is not going to use the state of the object to perform some business operation rather it use the parameterized data which is passes at the time of method calling.if an object does not have any state it useless to create the duplicate object for that class ,in this case better to create that class as singleton class.

04/05/2016 15:29:58

05/05/2016 11:54:14
because object creation is more costly and also performance will may decrease so if any where required singleton type class so I should always recommend to make class as a singleton

Languages :