In this post, we will see How To Write Apex Class in Salesforce | Apex Class for Beginners.
Program Code: (class Calc)
public class Calc {
public double result;
public double add(integer x, integer y)
{
result=x+y;
return result;
}
public double sub(integer x, integer y)
{
result=x-y;
return result;
}
}
Program Code: (code in Anonymous Window)
Calc c=new Calc();
double res;
res=c.add(3,5);
system.debug('Addition='+res);
res=c.sub(3,5);
system.debug('Difference='+res);
No comments:
Post a Comment