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 of util classes in apex


I want to know the details of utility class and use of it and how write the class ?

thanks in advance.

Jeff MayJeff May

You can just write the class and methods, then reference it in other Apex classes.


class MyUtil{


  public void myMethod(){






trigger myTrigger{


     MyUtil mu = new MyUtil();




Utility class can be any class which contain methods which might be used frequently in a lot of class in the SFDC instance. eg. you would need to get the name of the record type from the id. So you write a generic method in the utility class which does the job for you and you can reuse the code of that class.