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
Roy MooreRoy Moore 

Trailhead: Unclear instruction "Apex Basics & Database" Module - Unit 1/5

I'm just learning Apex and I am stuck on this step under "Call a Static Method"...

Modify the statements in your Execute Anonymous window to call the static method on the class name.

I opened the Execute Anonymous window, but I am not sure what to modify and how.  Any hints?

 
Best Answer chosen by Roy Moore
Shashikant SharmaShashikant Sharma
Static methods could directly be called by Class Name
Createa smaple class : It has a static variable and a static method
Public class StaticMethodContainerClass {

public static String nameVal = 'test';
public static void callStaticMethod( String updatedValue ) {
nameVal = updatedValue; 
}

}

In Developer console run :
system.debug ( ' Name : ' + StaticMethodContainerClass.nameVal );
system.debug ( ' Run execute method ' );
StaticMethodContainerClass.callStaticMethod( ' Updated Name' );
system.debug ( ' Name After Execution : ' + StaticMethodContainerClass.nameVal );

Let me know if you still have any questions.