Sign in to follow this  

SINGLETON PATTERN

This topic is 4105 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hallo! I am programming in java and I have to make sure that only one instance of a class is created. This instance should also be used by other classes. I am trying to use singleton but, it is not working.... This is how i want to get hold of my con: con c = new con.getTheOne_con(); but it's not correct because when I compile it I get that it can't be resolved to a type In my con class: private static con one_con = null; private con() { counter = counter +1; System.out.println("con created: "+ counter); } public static synchronized con getTheOne_con() { if(one_con == null) { one_con = new con(); } return one_con; } please help.....

Share this post


Link to post
Share on other sites

This topic is 4105 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.
Sign in to follow this