
Salesforce Apex Tutorial Chapter 14: Apex Objects

An object is an instance of a class. The object can be a class object in Salesforce, or it can also be an object of sObject.
Object creation In Apex: An object of the class can be created in the same way as created in Java or another object-oriented programming language.
Example:
public class DemoClass{
String salutation= ‘Mr.’;
public void methodName (String firstName) {
String fullName;
fullName= firstName +’:’+ salutation;
System.debug(fullName is '+fullName);
}}
DemoClass obj = new DemoClass(); // instance of above class
obj.methodName (‘Andrew’); // access method from above class
Comments are closed.