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

  • 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.

  • [adinserter block='9']
  • 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.