Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Single Instance of a class

  1. #1
    Member
    Join Date
    Mar 2011
    Posts
    114
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Single Instance of a class

    Singleton Design Pattern creates only one instance of a class per JVM. Is there any other way to create ONLY one instance of a class?


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Single Instance of a class

    For all intensive purposes yes.

    just make the constructors private.
    Last edited by helloworld922; August 28th, 2012 at 01:00 AM.

  3. The Following User Says Thank You to helloworld922 For This Useful Post:

    amitjava (August 28th, 2012)

  4. #3
    Junior Member psabbate's Avatar
    Join Date
    Aug 2012
    Posts
    20
    My Mood
    Amused
    Thanks
    0
    Thanked 5 Times in 4 Posts

    Default Re: Single Instance of a class

    Quote Originally Posted by tcstcs View Post
    Singleton Design Pattern creates only one instance of a class per JVM. Is there any other way to create ONLY one instance of a class?
    You mean besides Singleton Pattern? Basically the idea is a private constructor and some methods to access the instance, but I 'm not quite sure that I understand your question.
    Everyone wants to go to heaven ... but nobody wants to die

    Nissi Group, Servicios IT,
    Diseņo Web, Desarrollo de Software, SEO,
    LinkedIn

Similar Threads

  1. Best way to turn a single class into multiple classes
    By JoeBrown in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 21st, 2012, 11:57 AM
  2. How to return class instance?
    By nera1981 in forum JDBC & Databases
    Replies: 7
    Last Post: August 23rd, 2011, 01:14 PM
  3. Diff between spring created been and instance of class
    By tcstcs in forum Web Frameworks
    Replies: 0
    Last Post: April 5th, 2011, 12:54 AM
  4. Replies: 2
    Last Post: January 22nd, 2011, 11:20 PM
  5. Compare instance of a class to another
    By srs in forum Java Theory & Questions
    Replies: 5
    Last Post: December 2nd, 2010, 10:39 AM