Activity Forums Salesforce® Discussions What is difference between Singleton and immutable class?

  • What is difference between Singleton and immutable class?

    Posted by Marziya on December 21, 2020 at 1:02 PM

    What is difference between Singleton and immutable class?

    Shweta replied 5 years ago 3 Members · 2 Replies
  • 2 Replies
  • Anjali

    Member
    December 21, 2020 at 2:11 PM

    An immutable object is initialized by its constructor only, while a singleton is instantiated by a static method. A set of functions (or static methods) which manipulate some shared mutable state constitute a singleton. This implies that every mutable member of a singleton collection is itself a singleton.

  • Shweta

    Member
    December 24, 2020 at 5:19 PM

    Singleton object will have only one object and multiple states and Immutable object will have each new object with each time the state is changed.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos