write a sample code to create singleton class using java. ensure that only one instance will be creted and same will be returned always.


please do it.

sanjay

Recommended Answers

All 3 Replies

Make its constructor private and have a static method called instance(), inside this method create a instance only once , and return the same instance everytime this static method is called.

write a sample code to create singleton class using java. ensure that only one instance will be creted and same will be returned always.


please do it.

sanjay

Sanjay please do it on your own and return back when you get problem with code, not problem with personal lazines of actualy learning something.

Important thing is to read forums rules befor signing up for the forum. This forum doesn't provide solution to courseworks/assignments/project works. We help individuals which want to learn. Copy & paste somebody's work and put your signature bellow it is not our way of helping. If you want somebody else to do your work find other forum, but you will be charged for it...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.