0% found this document useful (0 votes)
7 views

Final Class Object

Apex Final Class

Uploaded by

lsrinivas.rpa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Final Class Object

Apex Final Class

Uploaded by

lsrinivas.rpa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Final: Any variable which is declared with the keyword Final is called final variables.

- If a variable is final, we can’t re-initialize the value


- If you want to declare any constants, then we should go for Final variables.

public double circleArea(){


Integer r=5;
double result = pi*r*r;
System.debug('Area of the circle is: ' +result);
return result;
}

Arrays:
- Array is a continuous memory allocation which can store homogeneous type of data.
- Array values are stored up on index. Starts with 0
- To calculate the length of an array we use size()

Integer[] ages = new Integer[5];


ages[0] = 30;
ages[1] = 40;
ages[2] = 25;
ages[3] = 50;
ages[4] = 32;

system.debug('RollNos = ' + ages [3]);

------------

for(Integer i = 0; i < ages.size(); i++){ //size() - to get the size of array


system.debug('i is = ' + ages[i]);
}

String[] names = new String[]{'ram','kiran', 'anita', 'sunita'};


system.debug('RollNos = ' + names[3]);
What is an Object?

Any real-world entity that we can imagine, see is an Object.


For example, Pen, Dog, Cat, Laptop, Mobile, Bottle, Car, Tree etc,

An object will have the following characteristics


- States: the properties or characteristics of the objects called variables
- Behaviour: What actions or functionalities an object can perform – Methods

Classes: Classes are the blueprints for the Objects and using Classes we can create 1 or multiple
Objects.
Members of the Class:

We have 3 members in class type:


1. Data members or variables, which are used to store data or value.
2. Function members or Methods: which are used to perform some operations
3. Constructers: it is a special member of the class which is used to initialize data members.

Methods:
- Reusable code snippet
- Specific purpose
- Knows what comes through
- Knows what goes out

In Salesforce Apex, a method is a block of code that can be called multiple times from within a class
or interface. Methods are used to perform specific actions, such as validating data, processing logic,
or interacting with external systems.
Person p1 = new Person();
p1.printDemo('sss');

-------------
public class Person {
public String firstName;
public String lastName;
public Integer age;

public void walking(){


System.debug('walk some distance');
}

public void walk(Integer distance){


System.debug('walk some distance'+distance);
}

public void talk(){


return 'Hello, my name is ' +firstname;
}

public class Person{

public void add(){


Integer a=10;
Integer b=20;
Integer c=a+b;
System.debug('C value is:'+c);

You might also like