
So, you have decided to commence your journey as a Salesforce developer and put your career in the fast-paced lane. Join us as you embark on this wonderful journey to become a champion Salesforce developer. In this module we will introduce the Salesforce platform and acquaint the attendees with Apex.
Agenda
- Declarative Vs Programmatic Approach of Development
- Datatypes in Apex
- Operators in Apex
- System.Debug()
- Familiarizing to Dev Tools – VS Code, Anonymous Block
- Q & A
Most importantly don’t break a leg if you are overwhelmed with the pace of the live sessions. All Apex Hours for Student sessions will be recorded and will be available on our YouTube channel. Please Subscribe our YouTube Channel.
Here is Keynote from our session
Why code?
- Customized applications
- Tailored organization processes
- Collaboration with external systems
- Custom logic
- Complex validation
What is Apex?
Strongly typed, object-oriented programming language that allows developers to execute flow & transaction control statements on Salesforce servers in conjunction with calls to the API.

Salesforce Application Anatomy

Data Types in Apex
Data Type | Description | Sample Value |
Blob (Binary Large Object) | Binary data stored as a single object. You can convert this data type to String or from String using the toString() and valueOf() methods, respectively. | VGhpcyBEb2N1bWVudCBjb250YWlucyBzYW1wbGUgdGV4dCBmb3IgdGhlIFZpc3VhbGZvcmNlIA0KRG9jdW1l |
Boolean | Logical value | True, False, null |
Date | Indicates a particular day. Unlike Datetime values, Date values contain no information about time. | 2020-02-10 |
Datetime | A value that indicates a particular day and time, such as a timestamp. | 2020-02-10 07:29:09 |
Time | A value that indicates a particular time. | 22:40:36.003Z |
Decimal | A number that includes a decimal point. Decimal is an arbitrary precision number. Currency fields are automatically assigned the type Decimal. | 27.0 |
Variables in Apex
Variables are in-memory containers that can hold data belonging to a specific data-types during processing and can be reused based on their scope.
Integer inValue = 27;
System.debug(‘ID :’ +inValue);
Demo 2: Using Variables & Operators in Apex
String o = ‘Hello World’; //String System.debug(‘Blob: ‘ + Blob.valueOf(o)); //Blob Boolean isActive = true; System.debug(‘Boolean: ‘ + isActive); //Boolean System.debug(‘Date: ‘ + Date.newInstance(2020, 01, 18)); //Date Datetime currDateTime = Datetime.now(); System.debug(‘Date: ‘ + currDateTime); //DateTime System.debug(‘Time: ‘ + Time.newInstance(22, 40, 36, 03)); //Time Decimal decValue = 27.01; System.debug(‘Decimal: ‘ + decValue); //Decimal Id recordId = [Select Id From Account Limit 1][0].Id; System.debug(‘ID: ‘ + recordId); //ID Integer intValue = 27; System.debug(‘Integer: ‘ + intValue); //Integer Long longValue = 2147483648L; System.debug(‘Long: ‘ + longValue); //Long Object objValue = o; System.debug(‘Object: ‘ + objValue); //Object |
Iterating Collections in Apex
5 Types of Procedural Loops in Apex
- Do {Code Block} While (Boolean Exit Condition)
- While (Boolean Exit Condition)
- For
- For (Initialization; Boolean Exit Condition; Increment) {Code Block}
- For (Variable : Array or Set) {Code Block}
- For (Variable : [Inline SOQL Query]) {Code Block}
Conditional Statements in A
- If Else…
- Switch Statements
- Ternary Operators
Collection in Apex
We have all below collection option in apex. Please check this post to learn more about collection in Apex.
- List
- Set
- Map
Demo 3 – Using Collections in Apex
List<Integer> listOfNumbers = new List <Integer> (); listOfNumbers.add(1); listOfNumbers.add(2); listOfNumbers.add(3); listOfNumbers.add(3); System.debug(‘listOfNumbers: ‘ + listOfNumbers); Set<Integer> setOfNumbers = new Set<Integer>(); setOfNumbers.add(3); setOfNumbers.add(2); setOfNumbers.add(2); setOfNumbers.add(1); System.debug(‘setOfNumbers: ‘ + setOfNumbers); Map <Integer,String> mapOfIntegerString = new Map <Integer,String> (); mapOfIntegerString.put(1, ‘one’); mapOfIntegerString.put(2, ‘two’); mapOfIntegerString.put(3, ‘three’); mapOfIntegerString.put(3, ‘four’); System.debug(‘mapOfIntegerString: ‘ + mapOfIntegerString); System.debug(‘Value at 3: ‘ + mapOfIntegerString.get(3)); |
Demo 4 – Using Loops in Apex
List<integer> listOfNumbers = new List <integer> (); Integer maxListSize = 5; for(Integer i = 1; i <= maxListSize; i++){ listOfNumbers.add(i); } System.debug(‘listOfNumbers: ‘ + listOfNumbers); |
When should I use Apex?

Recording
Here is link of recording
Episode 1 will be presented by Jigar Shah on Feb 10, 2020 at 6 PM Indian Standard Time.
Further Learning
Assignment
Complete below assignment to win $1000 Salesforce Voucher. Click here for rule.
Write an Apex program to store all the numbers in a List starting from 1 until 20. Only numbers stored at even positions in the List should be added to get their sum which should be output to the Debug Log. |
(Hint: Use a while loop and if else along with System. debug()
Don’t forget to register for our next session. Check this post for all other session details.
Please note that we have limit of 500 attendees that can join the online sessions. However, recording will be posted on our YouTube channel. Make sure to subscribe our YouTube channel to get notification for video upload.
So, learn at your pace and free will and ace your journey to Salesforce!
Thanks,
Comments(139)
Darshan says:
January 26, 2020 at 6:18 pmIs the link to join the live session if so I am unable to see it if you could share would be wonderful.
Amit Chaudhary says:
January 26, 2020 at 7:20 pmSay Connected we will share the registration link soon
Jessica says:
February 10, 2020 at 11:45 pmI have completed Assignment `
Lucien YSR OULA ☁️ says:
January 30, 2020 at 11:30 amOk 👌look forward to 👍
Rama says:
February 5, 2020 at 5:58 amplease share the link
Alisha says:
February 5, 2020 at 1:04 pmLink to join the session
Amit Chaudhary says:
February 6, 2020 at 3:43 amClick on registration link in the post
Pani says:
February 10, 2020 at 11:50 amAre you available on Udemy?
Amit Chaudhary says:
February 10, 2020 at 6:45 pmThis is totally free, We will upload on YouTube.
Seetharaman says:
February 11, 2020 at 10:49 amThanks for your videos. Waiting for upcoming videos.
Dhanalakshmi Vellachamy says:
February 10, 2020 at 2:04 pmDoes this entire Developer Program cover the Salesforce Developer Certification modules Or Does it help in Developer Certification?
Anuj Sahu says:
February 10, 2020 at 2:36 pmApexHours Completed my first Assignment of Apex. Looking forward to explore more
Amit Pande says:
February 10, 2020 at 2:53 pmHello Jigar/Apex Team – Thanks for a good starting session for Apex development today. Appreciate your team efforts on the same. I am aware it will take some time and efforts to upload daily recording on youtube and this site, however could you please upload daily ppt used and trailhead links immediately after each session so that we can refer them before next day’s session. Also seen that ppt is not uploaded for last year’s admin sessions and trailhead links for also few. Could you please check that once and upload ppt and trailhead links for all admin session? It will be very useful. – Amit
Amit Chaudhary says:
February 10, 2020 at 6:44 pmUploaded all content and Demo code as well
cBooM says:
March 10, 2020 at 10:47 pmwhere ? 🙁
Dhanalakshmi Vellachamy says:
February 10, 2020 at 3:10 pmAssignment Answer :
Integer listSize = 20;
Integer sum=0;
for (Integer i =1; i<=listSize; i++)
{
testList.add(i);
}
Integer count = 0;
while(count < 20 )
{
if(math.mod(count, 2) == 0)
{
sum = sum + testList[count];
}
count++;
}
System.debug('Total Sum is ' +sum);
// Total Sum is 100
Aswini says:
December 2, 2020 at 2:08 pminteger sum=0;
list listnumber=new list();
integer i=1;
while(i<=20)
{
listnumber.add(i);
i++;
}
System.debug('listnumber 1 to 20:'+listnumber);
for(integer i=1;i<listnumber.size();i++)
{
if(Math.mod(listnumber[i], 2)==0)
{
sum=sum+listnumber[i];
System.debug('totalsum value:'+sum);
}
}
System.debug('final totalsum::'+sum);
out put:istnumber 1 to 20:1,2,3,4,5,6,7,8,9,10……
inal totalsum::110
Arnab Saha says:
May 14, 2021 at 11:41 aminteger totalssum=0;
list listofnumbers=new list();
for( integer i=1; i<=20 ; i++)
{
listofnumbers.add(i);
}
System.debug('listnumbers 1 to 20:'+listofnumbers);
for(integer i=1;i<listofnumbers.size();i++)
{
if(Math.mod(listofnumbers[i], 2)==0)
{
totalssum=totalssum+listofnumbers[i];
System.debug('totalsum value:'+totalssum);
}
}
System.debug('final totalsum::'+totalssum);
Arnab Saha says:
May 14, 2021 at 11:42 amlistofnumbers ko integer define karo
Amit Chaudhary says:
May 19, 2021 at 10:29 amThanks for helping
ritanshu kumar says:
June 2, 2021 at 5:07 amtotalsum::210
Asmita says:
February 10, 2020 at 3:28 pmCompleted the assignment
Asmita says:
February 10, 2020 at 3:30 pmCompleted the assignment for day 1
Archit Dutt Sharma says:
February 10, 2020 at 3:36 pmCompleted the first assignment
Isaac Arcos Huicochea says:
February 10, 2020 at 4:25 pmCompleted the first Assignment
Venkatesh says:
February 10, 2020 at 6:46 pmMany thanks for arranging sessions even in busy schedules. Really appreciate your team efforts.
I have completed first assignment.
Venkatesh says:
February 10, 2020 at 6:50 pmMany thanks for arranging sessions even in your busy schedules. Really appreciate your team efforts.
I have completed first assignment given today.
Ankit Desai says:
February 10, 2020 at 7:59 pmCompleted Assignment for Day 1
Ankit Desai says:
February 10, 2020 at 8:19 pmCompeted Assignment for day 1
Dave says:
February 10, 2020 at 8:22 pmI realize that it takes time to accomplish this, but the sooner you could post the video to Youtube the better. For me, it is 4:30am for the sessions. I made it today and fell asleep during it. It had nothing to do with you guys! It was just too early in the morning to be awake. I’d love to be able to schedule watching the video the same day it was done and do the work.
Thanks for being awesone!
Amit Chaudhary says:
February 10, 2020 at 8:25 pmWe will upload all recording by 6 MARCH
Sadaf Khan says:
February 11, 2020 at 2:04 amThanks
Assignment Complete-Day 1
Natalya says:
February 10, 2020 at 9:29 pmWohoo, my assignment 1 is complete 🙂 Thank you so much for running these sessions, guys!
Ajay Gupta says:
February 11, 2020 at 1:05 amCompleted the assignment of Day 1.
Sadaf Khan says:
February 11, 2020 at 1:28 amDay 1 -Assignment Complete
Thank you for hosting these sessions.
Bhargavi says:
February 11, 2020 at 1:30 amMy assignment for Day 1 is complete
Sadaf Khan says:
February 11, 2020 at 1:46 amDay 1- Assignment Completed.
Thank you for hosting these session.
Sadaf Khan says:
February 11, 2020 at 2:03 amAssignment Complete
Vikas Sharma says:
February 11, 2020 at 3:13 amThank you Jigar/Amit for this amazing Initiative.
Completed my assignment for Day#1
Shaik says:
February 11, 2020 at 3:38 amDone with assignment. Thanks
Quang Du says:
February 11, 2020 at 4:01 amAssignment 1 completed. Thank you deeply for this learning opportunity.
Quang Du says:
February 11, 2020 at 4:03 amAssignment 1 completed. Thank you!
Quang says:
February 11, 2020 at 4:10 amAssignment 1 completed. Thank you!
Latha Vemula says:
February 11, 2020 at 4:24 amThank you guys so much for motivating other to learn with your good work. This is really exciting and definitely a staring point for people like me to achieve goals to become a salesforce developer. Assignment is completed for day1 #Apexhours session. Looking forward to learn and experience the awesomeness with in this journey.
A Belano says:
February 11, 2020 at 5:03 amCompleted Assignment for Day 1. Great first session. Excited to learn more!
A Belano says:
February 11, 2020 at 5:07 amCompleted Day 1 Assignment
A Belano says:
February 11, 2020 at 5:16 amAssignment for Day 1 completed!
isthiyaq ahamed says:
February 11, 2020 at 5:56 amCompleted the assignment for day 1
Erick says:
February 11, 2020 at 6:07 amCompleted the assignment for day 1.
Erick says:
February 11, 2020 at 6:08 amCompleted the assignment for day 1.
Erick says:
February 11, 2020 at 6:11 amCompleted the assignment for day 1
Vandana says:
February 11, 2020 at 6:34 amFirst Assignment completed
Aathirai says:
February 11, 2020 at 6:54 amCompleted Day 1 Assignment. Waiting eagerly for the next session.
Aathirai says:
February 11, 2020 at 6:57 amCompleted Day 1 Assignment.
Vanita Sangle says:
February 11, 2020 at 7:12 amCompleted assignment for session 1 ..thank you for your efforts..
Vanita Sangle says:
February 11, 2020 at 7:21 amCompleted assignment 1..thank you.
waruna says:
February 11, 2020 at 7:24 amCompleted the assignment
Diksha Chhabra says:
February 11, 2020 at 7:58 amThannks for the valuable session.
Introduction to Apex Part 1 : Assignment completed
Rishab Goyal says:
February 11, 2020 at 8:00 amCompleted Assignment 1
Surabhi says:
February 11, 2020 at 8:28 amcompleted
Surabhi says:
February 11, 2020 at 9:03 amCOmpleted assignment 1 .:)
Akhil Kulshrestha says:
February 11, 2020 at 9:14 amthe assignment is complete
Prakash says:
February 11, 2020 at 9:15 amsuccessfully completed assignment1 🙂
surabhi says:
February 11, 2020 at 9:45 amList mylist=new list();
Integer sum=0;
for (Integer i =1; i<=20; i++)
{
mylist.add(i);
//system.debug(mylist);
}
Integer j = 0;
while(j < 20 )
{
integer check=math.mod(j, 2);
if(check == 0)
{
sum = sum + mylist[j];
}
j++;
}
System.debug('Sum is ' +sum);
Deepak Sah says:
February 11, 2020 at 9:54 amThank you so much for wonderful session.
Assignment is completed.
Deepak Sah says:
February 11, 2020 at 10:21 amCompeted Assignment for day 1
Marishell Cruz says:
February 11, 2020 at 11:20 amCompleted first assignment for day 1
Nishith Agrawal says:
February 11, 2020 at 12:03 pmCompleted assignment for day1.
Praveen says:
February 11, 2020 at 12:11 pmApexHours is the best platform that i have seen so far. Thanks for helping people to code. Its is good initiative by the great people working on Salesforce Platform to help people code.
Thanks for all you hard work to keep this running!! 🙂
I have completed Assignment 1.
Praveen Venkata says:
February 11, 2020 at 12:23 pmIt’s a great platform to interact with all great leaders who initiated this program to help people learn code.
Completed Assignment 1.
Preeti says:
February 11, 2020 at 2:01 pmHi ..Thanks for the really useful and knowledgeable session..Completed Assignment for Day1.
Preeti says:
February 11, 2020 at 2:02 pmThanks for the wonderful session.Completed Assignment 1 of Day 1
Paranthaman K says:
February 11, 2020 at 2:10 pmAssignment Completed..
Paranthaman K says:
February 11, 2020 at 2:11 pmAssignment 1 Completed..
Quang says:
February 11, 2020 at 5:21 pmAssignment 1 completed.
Bhavin says:
February 12, 2020 at 12:38 amAssignment day#1
—————————-
Integer totalsum=0;
List numbers = new List();
for (Integer i = 1; i <= 20; i ++)
{
numbers.add(i);
}
//System.debug('listofnumbers'+ numbers);
for (Integer i=1;i<numbers.size();i++)
{
if (Math.mod(numbers[i],2)==0)
{
totalsum= totalsum + numbers[i];
}
}
System.debug('total sum is'+totalsum);
Bhavin says:
February 12, 2020 at 12:40 amAssignment#1
————————
Integer totalsum=0;
List numbers = new List();
for (Integer i = 1; i <= 20; i ++)
{
numbers.add(i);
}
//System.debug('listofnumbers'+ numbers);
for (Integer i=1;i<numbers.size();i++)
{
if (Math.mod(numbers[i],2)==0)
{
totalsum= totalsum + numbers[i];
}
}
System.debug('total sum is'+totalsum);
Gugulothu Anil says:
February 12, 2020 at 5:05 amassignment is completed
Arjinder Kaur says:
February 12, 2020 at 7:29 amAssignment done
Arjinder Kaur says:
February 12, 2020 at 7:31 amDay1 Assignment done
Modi says:
February 12, 2020 at 10:52 amHello,
Assignment Day 1 completed.
Integer Totalsum = 0;
List listOfNumbers = New List ();
For(Integer i=0; i<20; i++){
listOfNumbers.add(i+1);
}
System.debug('listOfNumbers:' +listOfNumbers);
For(Integer j=0; j<20; j++){
if(Math.mod(j,2)==0){
Totalsum = Totalsum +listOfNumbers[j];
System.debug('Totalsum value:' +Totalsum);
}
}
System.debug('Final summation:' +Totalsum);
Brisilda says:
February 12, 2020 at 12:01 pmDay 1 Assignment is completed!
balaji manikandan says:
February 13, 2020 at 6:30 amDay 1 Assignment is completed.
balaji manikandan says:
February 13, 2020 at 8:10 amAssignment 1 completed
Keerthana Ramesh says:
February 13, 2020 at 8:27 amCompleted Day 1 Assignment
Michael Wind says:
February 13, 2020 at 1:20 pmcomplete Assigment Day 1
Chetan Sharma says:
February 13, 2020 at 7:31 pmCompleted Day 1 assignment
Rana Khan says:
February 13, 2020 at 7:53 pmCompleted the Assignment
SaiSagar says:
February 14, 2020 at 11:51 amDay 1 Assignment Done
Thanks
Sai Sagar says:
February 14, 2020 at 11:52 amDay 1 Assignment Done
Thanks
Raman Chopra says:
February 15, 2020 at 5:26 amDay 1 Assignment is completed.
Raman Chopra says:
February 15, 2020 at 5:35 amDay1 Assignment Completed
Otieno says:
February 15, 2020 at 7:07 amThanks for hosting this awesome session.
Really looking forward my SalesForce Dev Career.
Day 1- Assignment Completed.
Otieno says:
February 15, 2020 at 11:35 amAssignment 1: Completed.
Thanks for the upskilling opportunity.
Adnan says:
February 15, 2020 at 3:56 pmDay 1 Assignment Complete
Titli Banerjee says:
February 16, 2020 at 3:53 pmAssignment is complete
Raman Chopra says:
February 16, 2020 at 4:01 pm#ApexHoursDev @ApexHours
Day1 Assignment Completed
crystal says:
February 17, 2020 at 1:43 amInteger Totalsum = 0;
List listOfNumbers = New List ();
For(Integer i=0; i<20; i++){
listOfNumbers.add(i+1);
//System.debug (listOfNumbers[i]);
}
System.debug('listOfNumbers:' +listOfNumbers);
For(Integer j=0; j<20; j++){
if(Math.mod(j+1,2)==0){
Totalsum = Totalsum +listOfNumbers[j];
//System.debug('Totalsum value:' +Totalsum);
}
}
//Final Summation: 110
System.debug('Final Summation:' +Totalsum);
crystal says:
February 17, 2020 at 1:46 amDay1 Assignment Completed
crystal says:
February 17, 2020 at 1:52 amInteger totalsum=0;
List numbers = new List();
for (Integer i = 1; i <= 20; i ++)
{
numbers.add(i);
}
//System.debug('listofnumbers'+ numbers);
for (Integer i=1;i<numbers.size();i++)
{
if (Math.mod(numbers[i],2)==0)
{
totalsum= totalsum + numbers[i];
}
}
System.debug('total sum is'+totalsum);
Siva Kumar Gampala says:
February 17, 2020 at 11:51 amI am new to Salesforce ecosystem and interested in development .Luckily I got to know about this program and started my SalesforceDevelopment journey with ApexHours.Thank you for the great content and helping the community.
Imtiaz Ali says:
February 17, 2020 at 7:43 pmGreat platform and it help people to learn code. i am new to the world however, looks with your support i would be able to learn much!
Jaya Iyer says:
February 17, 2020 at 11:53 pmAssignment 1 Complete
James Fody says:
February 18, 2020 at 3:56 pmAssignment 1 complete
Shilpa Srikantachar says:
February 18, 2020 at 5:09 pmDAY 1 Assignment Complete
This is a great initiative and love the great content .
Being a Salesforce Admin , trying to transition to being a Developer .Hope I get there .
Anand says:
February 26, 2020 at 5:41 amI just went through the Apex hours DAY 1 Video. Its very usefull and I have completed the assignment 1:
Integer sumofnum = 0;
List listofn = new List();
for (Integer i=1; i<=20; i++){
listofn.add(i);
}
System.debug('listofn: '+listofn);
for (Integer i=1; i < listofn.size(); i++){
if(Math.mod(listofn[i],2) ==0){
sumofnum = sumofnum + listofn[i];
system.debug('sumofnum: ' + sumofnum);
}
}
system.debug('Finalsumofnumbers: ' + sumofnum);
Pritam Pramod Dalvi says:
February 26, 2020 at 11:39 amDay 1 Assignment Completed.
Louis Macwan says:
February 28, 2020 at 7:27 amDay 1 Assignment Completed.
Sonia Soni says:
March 5, 2020 at 5:47 amDone with Day 1 assignment
ASHOK KUMAR PANIGRAHI says:
March 10, 2020 at 11:25 pm#ApexHoursDev @ApexHours
Day1 Assignment Completed
NARESH CHANDA says:
March 12, 2020 at 4:16 amDay 1 Assignment Completed.
Pratik Pandey says:
March 12, 2020 at 4:16 pmDay 1 assignment completed
kushagra bhardwaj says:
April 3, 2020 at 10:24 amThank you so much for these sessions. It really means a lot.
completed assignment one.
I just encountered an issue when going through part one of basic loops.
Program which you have created at 1:18:43, the second loop to add the even numbers.
The loop you started was from index 1 but it should be from 0.
Correct me if i am wrong.
Ankit Desai says:
April 10, 2020 at 8:47 pmCode for Assignment Day 1
——————————–
Integer countSize = 20;
Integer counter = 0;
Integer sum=0;
List listOfNumbers = new List ();
for (Integer i =1; i<=countSize; i++){
listOfNumbers.add(i);
}
System.debug('Size of list:' +listOfNumbers.size());
while(counter < listOfNumbers.size() ){
if(math.mod(counter, 2) == 0){
sum = sum + listOfNumbers[counter];
}
counter++;
}
System.debug('Total Sum for numbers which stored at even positions:' +sum);
Hurmat says:
August 12, 2020 at 4:27 pmHi Ankit,
Integer countSize = 20;
Integer counter = 0;
Integer sum=0;
List listOfNumbers = new List ();
for (Integer i =1; i<=countSize; i++){
listOfNumbers.add(i);
system.debug('the list'+i);
}
System.debug('Size of list:' +listOfNumbers.size());
while(counter<listOfNumbers.size() ){
if(math.mod(listOfNumbers[counter], 2) == 0){
sum = sum + listOfNumbers[counter];
system.debug('the value of sum' +sum);
}
counter++;
}
System.debug('Total Sum for numbers which stored at even positions:' +sum);
The sun should come as 110
Jim says:
June 6, 2020 at 9:56 pmI realize this training has ended and I attempted the assigments, firstly for Assignment 1; Where can i find the answers to see if I am correct.
Amit Chaudhary says:
June 6, 2020 at 11:35 pmJust check the other comment in this post only
prateek alavadi says:
July 24, 2020 at 1:03 pminteger Sum=0;
List listOfNumbers = new List();
for(integer i=1; i<=20; i++){
listOfNumbers.add(i);
}
System.debug('The list of Numbers Are:-'+listOfNumbers);
for(integer i=0; i<20; i++){
if(math.mod(i,2)==0){
sum=sum+listOfNumbers[i];
}
}
System.debug('The addition is:-'+sum);
sirish says:
August 16, 2020 at 2:40 pmList listOfNumbers = new List ();
Integer maxListSize = 20;
integer j=0;
for(Integer i = 1; i <= maxListSize; i++){
listOfNumbers.add(i);
j=listOfNumbers.size();
}
integer i=0;
integer k=0;
for(i=0;i<=j;i+=2)
{
k=k+i;
}
System.debug(k);
Priyanka says:
September 24, 2020 at 7:19 amInteger sum=0;
List numList= new List();
for (Integer i=0; i<=20; i++)
{
numList.add(i);
}
system.debug('numbers added' +numList);
for(Integer count=1;count<numList.size();count++)
{
if(Math.mod(numList[count], 2)==0)
{
sum= sum + numList[count];
}
}
system.debug('numbers added in even list' +sum);
Answer is 110
Rahul Das says:
October 13, 2020 at 7:17 pmHi i am Rahul… I love the way you guys delivery the session. Now i am preparing for developer role. But i can see the developer playlist is not completed. Can you update the playlist with all the video.
Thank you in advance 🙂
Amit Chaudhary says:
October 13, 2020 at 8:04 pmHere is all recording https://www.youtube.com/playlist?list=PLaGX-30v1lh1e8roeCUumUEel5ukdPubj
Nia says:
December 7, 2020 at 1:58 pmCan you please upload the full ppt showed in videos for every session in .ppt format same as video
Sravani says:
December 31, 2020 at 1:01 amInteger listSize = 20;
Integer sum=0;
list testList = new list();
for (Integer i =1; i<=listSize; i++)
{
testList.add(i);
}
System.debug('list' + testlist);
Integer count = 0;
while(count < 20 ){
if(math.mod(count, 2) == 0){
sum = sum + testList[count];
}
count++;
}
System.debug('Total Sum is ' +sum);
Total Sum is 100
Amit Chaudhary says:
January 1, 2021 at 3:28 pmKeep learning
Aruna Devkar-Mulik says:
March 15, 2021 at 2:35 pmList oddNumList=new List();
for(Integer i=1;i<=20;i++)
{
if(Math.mod(i,2)!=0)
{
oddNumList.add(i); //List will contain all odd numbers from 1 t 20
}
}
System.debug('List of Odd numbers : '+oddNumList);
Integer sum=0;
Integer count = 1;
while(count< oddNumList.size())
{
System.debug('count is :'+(count+1)+' Number at count is : '+oddNumList[count]);
/*
List index starts from 0 so to add numbers at even position we need to consider odd index
list -1,3,5,7,9,11,13,15,17,19 for us even position numbers are 3,7,11,15 & 19
*/
if(math.mod(count, 2) != 0)
{
sum = sum + oddNumList[count];
}
count++;
}
System.debug('Total Sum is ' +sum);
Waqar says:
May 24, 2021 at 2:33 amlist myEvenList = new list();
integer sum = 0;
for(integer i=1; i<=20; i++)
{
Integer reminder = math.mod(i, 2);
if(reminder == 0){
system.debug('Even: '+i);
sum = sum + i;
system.debug('Sum '+sum);
}
}
Sidhant says:
May 27, 2021 at 4:01 pminteger totalSum=0;
List listOfNumbers = new List();
for(integer i=1; i<=20; i++){
listOfNumbers.add(i);
}
System.debug('listOfNumbers: ' + listOfNumbers);
integer i=1;
While(i < listOfNumbers.size()){
if(Math.mod(listOfNumbers[i],2)==0){
totalSum = totalSum + listOfNumbers[i];
System.debug('totalSum Value: ' + totalsum);
}
i++;
}
System.debug('Final sumation: ' + totalSum);
Dheeraj Gurbani says:
September 23, 2021 at 2:31 ampublic class ApexHours1 {
public static void main(){
Integer sum = 0;
List iList = new List();
for(Integer i = 0; i < 20; i++){
iList.add(i);
if(math.mod(i, 2) == 0){
sum = sum + i;
}
}
System.debug(sum);
}
}
Gajraj Solanki says:
November 13, 2021 at 5:11 amInteger Sum = 0;
Integer A= 20; //First 20 Numbers
List NumList= New List();
For (Integer i=0; i<=A; i++){
Numlist.add(i);
}
System.debug(NumList);
For(Integer i=0; i<Numlist.size(); i++){
If(Math.mod(NumList[i], 2)==0){
Sum= sum+i;
}}
System.debug(Sum);
Saurabh Bambal says:
December 5, 2021 at 3:06 aminteger sum=0;
integer listsize=20;
listnum = new list();
integer i=1;
while(i<=20){
num.add(i);
i++;
}
system.debug('num 1 to 20:' +num);
for(integer i=1;i<num.size();i++){
if(Math.mod(num[i],2)==0){
sum=sum+num[i];
system.debug('totalsum value:'+sum);
}
}
system.debug('final totalsum:'+sum);
Saurabh Bambal says:
December 5, 2021 at 3:37 aminteger sum=0;
integer listsize=20;
listnum = new list();
integer i=1;
while(i<=20){
num.add(i);
i++;
}
system.debug('num 1 to 20:' +num);
for(integer i=0;i<num.size();i++){
if(Math.mod(i,2)==0){
sum=sum+num[i];
system.debug('totalsum value:'+sum);
}
}
system.debug('final totalsum:'+sum);
Saurabh Bambal says:
December 5, 2021 at 7:27 aminteger sum=0;
integer listsize=20;
listnum = new list();
integer i=1;
while(i<=20){
num.add(i);
i++;
}
system.debug('num 1 to 20:' +num);
for(integer i=0;i<num.size();i++){
if(Math.mod(i,2)==0){
sum=sum+num[i];
system.debug('totalsum value:'+sum);
}
}
system.debug('final totalsum:'+sum);
Mohit Jaiswal says:
February 20, 2022 at 11:14 amAssignment is complete!
Integer MaxListSize = 20;
Integer EvenSum = 0;
List OddListOfNo = new List();
for(Integer i= 1; i<= MaxListSize; i=i+2 )
{
OddListOfNo.add(i);
}
System.debug('List of Odd Numbers: ' + OddListOfNo);
//List of Odd Numbers: 1,3,5,7,9,11,13,15,17,19
System.debug('Size of Odd Numbers: ' + OddListOfNo.size());
//Size of Odd Numbers: 10
for(Integer i = 0; i < 10; i++)
{
if(Math.mod(OddListOfNo[i],2) != 0)
{
EvenSum = EvenSum + OddListOfNo[i];
System.debug('Sum of Even Position Numbers: ' + EvenSum);
i++;
}
}
System.debug('Sum of Even Position Numbers: ' + EvenSum);
//Sum of Even Position Numbers: 45
Mohit Jaiswal says:
February 20, 2022 at 11:21 amUpdated Answer
Integer MaxListSize = 20;
Integer EvenSum = 0;
List OddListOfNo = new List();
for(Integer i= 1; i<= MaxListSize; i=i+2 )
{
OddListOfNo.add(i);
}
System.debug('List of Odd Numbers: ' + OddListOfNo);
//List of Odd Numbers: 1,3,5,7,9,11,13,15,17,19
System.debug('Size of Odd Numbers: ' + OddListOfNo.size());
//Size of Odd Numbers: 10
for(Integer i = 0; i < OddListOfNo.size(); i++)
{
EvenSum = EvenSum + OddListOfNo[i];
System.debug('Sum of Even Position Numbers: ' + EvenSum);
i++;
}
System.debug('Sum of Even Position Numbers: ' + EvenSum);
//Sum of Even Position Numbers: 45
Rajesh Patil says:
March 7, 2022 at 1:49 amList listOfNumbers = new List();
integer i=1;
while(i<=20){
listOfNumbers.add(i);
i++;
}
System.debug('The list of Numbers Are:-'+listOfNumbers);
integer Sum=0;
for(integer i=0; i<20; i++){
if(math.mod(listOfNumbers[i],2)!=0){
sum=sum+listOfNumbers[i];
System.debug('The addition is:'+sum);
}
}
System.debug('The addition is:'+sum);
Rajesh Patil says:
March 7, 2022 at 1:51 amList listOfNumbers = new List();
integer i=1;
while(i<=20){
listOfNumbers.add(i);
i++;
}
System.debug('The list of Numbers Are:-'+listOfNumbers);
integer Sum=0;
for(integer i=0; i<20; i++){
if(math.mod(listOfNumbers[i],2)==0){
sum=sum+listOfNumbers[i];
System.debug('The addition is:'+sum);
}
}
System.debug('The addition is:'+sum);
Digvijay says:
April 3, 2022 at 7:57 amList listofNumbers = new List();
Integer maxSize = 20;
Integer sum = 0;
Integer x = 1;
while(x <= maxSize)
{
listofNumbers.add(x);
if(Math.mod(x,2)==0)
sum = sum + x;
x++;
}
System.debug('Sum of digits at even numbers is : ' + sum);
Camille Gonzalez says:
May 5, 2022 at 10:27 pmInteger totalSum = 0;
List listOfNumbers = new List();
for(Integer i = 1; i <= 20; i++){
listOfNumbers.add(i);
}
system.debug('listOfNumbers: '+ listOfNumbers);
for(Integer i = 1; i < listOfNumbers.size(); i++){
if(Math.mod(listOfNumbers[i],2) == 0){
totalSum = totalSum + listOfNumbers[i];
system.debug('totalSum Value: ' + totalSum);
}
}
system.debug('Final sum: '+ totalSum);