Activity Forums Salesforce® Discussions Using return in Apex

  • Using return in Apex

    Posted by Anurag on September 5, 2018 at 1:37 pm

    While returning in an Apex class, can we call the method from  another class directly in it ?

    For eg-

    return abc.xyz(a);

    where abc is another class and xyz is method in that class with 'a' as a parameter.   Is this correct ?

    Avnish Yadav replied 6 years, 3 months ago 4 Members · 3 Replies
  • 3 Replies
  • shariq

    Member
    September 5, 2018 at 1:48 pm

    HI Anurag,

    Yes, You can call the method from  another class directly.

    Hope this helps.

     

  • Parul

    Member
    September 5, 2018 at 1:49 pm

    Hi Anurag,

    Yes if the return type of method of class1 and class2 is same then we can call the method of class2 from return of method of class1

     

    e.g.

    Class1

    public class Class1{

    public string methodtoreturnString1(){

    return Class2.methodtoreturnString2();

    }

    }

    public class Class2{

    public string methodtoreturnString2(){

    return 'Salesforce';

    }

    }

    Thanks

     

     

  • Avnish Yadav

    Member
    September 5, 2018 at 2:02 pm

    Hi Anurag,

    Yes, you can call the method from another class directly in it .

    Thanks.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos