function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Use if interface in salesforce?



What is the use of interface and where to use it?

is there any addded advantages for using interface?


Shashikant SharmaShashikant Sharma

Interface is a class which contain all unimplemented methods( can call them also abstract methods)

We will implement these methods in derived class of interface.
ie an interface is actually not inherited but implemented.

We cann't create an instance of interface object instead we can create an instance for derived class objects


When to Use : 

If the requirement is like that something in your design changes frequently then go for interfaces instead of classes .


benefit of using interfaces is that they simulate multiple inheritance


On Apex Example Could be that if you want to implement an interface differenctly for syatem admin user and other users profile users.