You need to sign in to do that
Don't have an account?

How to access methods from other classes in apex
Hi,
How I can access methods from different class ( static / through instance variable ).
e.g.
I need something like this -
Thanks,
Abhishek
How I can access methods from different class ( static / through instance variable ).
e.g.
I need something like this -
public class A { public void callA(){ : } } public class B { public void callB() { A obj = new A(); obj.callA(); } }
Thanks,
Abhishek
More information around static and instance (https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_static.htm)
For static method ina class,
public class sample{
public static void method(){
System.debug('Testing');
}
}
In Annonymous window, we call as sample.method(); ,then testing output will be diaplayed.
If we access any method except static,then we use
public class sample1{
public void method1(){
System.debug('Access');
}
}
In Annonymous window, First create object for this class with the help of new operator and then call method with object.
sample1 sam= new sample1();
sam.method1();