Basics of Apex programming

In this tutorial, we will learn about apex programming. We will learn about classes, Datatypes, Variables and constants.

What is Apex class?

A class is a template through which we create objects. A class contains group of variables and methods. We can create object using the class.

Data types and variables- Basics of Coding

In any programming language, we need to store data and data can be in the form of numbers, string etc. In order to store data we need variables. Each variable should have a data type. Data types are used to define variables and methods in classes. In apex, all variables and expressions should have data types.
Below are some of the Apex Data types

  • Primitive data types( Integer, Boolean, String … etc)
  • Enum (an enumerated list)
  • sObjects (sObjects, or Account, Contact, object__c)
  • Collection(list,Set, Map)
  • Null (for the null constant. which can be assigned to any variable)
  • An Object created by the user: Classes created by the user

Primitive Data Types

Enumerated List or Enum data type: Enumerated list (or Enum) is an abstract data type that stores one value of a finite set of specified identifiers.
If we wanted a variable to store values like {Winter, Summer, Spring } then in this case we will create Enum.
To define Enum, we use Enum Keyword in the variable declaration and then define the list of values.

sObjects

Collection Data types: There are three main types of collections available in Apex.
List: An ordered collection of elements. In the list, each element has an index number which starts from 0. Duplicate values are allowed in the case of List.
Set: An unordered collection of unique primitives. Set does not include duplicate elements.
Map: A collection of key-value pair.

This Post Has 44 Comments

  1. Emmett

    Hi there, I discovered your site by means of Google while searching for a similar topic,
    your website came up, it appears good. I have bookmarked
    it in my google bookmarks.
    Hi there, simply became alert to your weblog through Google, and located that it is truly informative.

    I am gonna watch out for brussels. I’ll be grateful if you happen to proceed this in future.
    A lot of other folks can be benefited out of your writing.

    Cheers!

  2. Mercedes

    What’s up to every one, the contents existing at
    this web page are truly amazing for people experience, well,
    keep up the good work fellows.

  3. Oh my goodness! Incredible article dude! Thank you, However
    I am experiencing problems with your RSS. I don’t understand
    the reason why I cannot join it. Is there anybody having similar RSS issues?
    Anyone who knows the solution can you kindly respond?
    Thanks!!

  4. Lauren

    Hmm is anyone else experiencing problems with
    the images on this blog loading? I’m trying to find out if its a problem on my end or if it’s the blog.

    Any feed-back would be greatly appreciated.

  5. mtpolice24

    I’m curious to find out what blog system you’re using?

    I’m experiencing some small security issues with my latest website
    and I’d like to find something more safe. Do
    you have any recommendations?

  6. Penny

    I’m not sure where you’re getting your information, but great
    topic. I needs to spend some time learning more or understanding more.
    Thanks for fantastic information I was looking for this info for
    my mission.

  7. Tracey

    Thanks for sharing such a nice thought, post is good, thats why i have read it entirely

  8. Wilhemina

    Great blog here! Also your site loads up very fast! What host are you using?
    Can I get your affiliate link to your host? I wish my web site loaded up as quickly as yours lol

  9. berkey

    Greetings I am so grateful I found your blog page, I really found you by error, while I was researching on Aol for something else, Anyhow I am here now and would just like to say thanks a lot for a fantastic post and a all round thrilling blog (I also love the theme/design), I don’t have time to go through it all at the minute but I have book-marked it and also included your RSS feeds, so when I have time I will be back to read a lot more, Please do keep up the awesome jo.|

  10. Cathern

    Simply wish to say your article is as astounding. The clarity in your post is just excellent and i can assume you are an expert on this subject.
    Fine with your permission let me to grab your RSS feed
    to keep updated with forthcoming post. Thanks a million and please continue the rewarding work.

  11. Maggie

    Good day! I simply wish to offer you a big thumbs up for your excellent information you have right here on this post.

    I am returning to your website for more soon.

  12. Leon

    Hi, There’s no doubt that your site might be having browser compatibility
    problems. Whenever I look at your website in Safari, it looks fine but when opening
    in I.E., it has some overlapping issues. I simply wanted to give you a quick
    heads up! Apart from that, fantastic website!

  13. Napoleon

    Hi there mates, how is the whole thing, and what you desire
    to say on the topic of this paragraph, in my view its really remarkable in support of
    me.

  14. Greg

    It is really a great and helpful piece of info.
    I’m satisfied that you just shared this helpful information with us.
    Please keep us up to date like this. Thank you
    for sharing.

  15. Larhonda

    Hey there just wanted to give you a quick heads up
    and let you know a few of the pictures aren’t loading correctly.
    I’m not sure why but I think its a linking issue.

    I’ve tried it in two different internet browsers and both show the same results.

  16. Carmelo

    Its like you read my mind! You seem to know a lot about
    this, like you wrote the book in it or something. I think
    that you can do with a few pics to drive the message home a little
    bit, but instead of that, this is wonderful blog.
    A fantastic read. I will definitely be back.

  17. Jamie

    You can definitely see your expertise in the article you write.
    The arena hopes for even more passionate writers such as you who
    aren’t afraid to mention how they believe. Always follow your heart.

  18. Joann

    For most recent information you have to visit world
    wide web and on world-wide-web I found this web site as
    a best website for most recent updates.

  19. sex toys uk

    Hello there! This article could not be written any better!
    Reading through this article reminds me of my previous roommate!
    He continually kept talking about this. I am going to
    forward this post tto him.Fairly certain he will have a good
    read. Thank you for sharing!

  20. Alba

    Howdy! Someone in my Myspace group shared this site with us so I came
    to give it a look. I’m definitely loving the information. I’m bookmarking and will be tweeting this to my followers!
    Great blog and amazing style and design.

  21. Constance

    Howdy! I realize this is sort of off-topic however I had to
    ask. Does running a well-established website such as yours take a lot of work?
    I am brand new to writing a blog however I do write in my journal daily.
    I’d like to start a blog so I can easily share my personal
    experience and thoughts online. Please let me know if you have any kind of recommendations or tips
    for new aspiring bloggers. Thankyou!

  22. Hmm is anyone else experiencing problems with the images on this blog loading?

    I’m trying to find out if its a problem on my end or if it’s the
    blog. Any suggestions would be greatly appreciated.

  23. Jenifer

    What’s up, its nice post regarding media print, we all
    understand media is a great source of information.

  24. Miriam

    Greetings! Very useful advice in this particular post!
    It is the little changes that produce the largest changes.
    Thanks for sharing!

  25. Alina

    Everything is very open with a clear explanation of the challenges.
    It was truly informative. Your site is very useful. Thank you for
    sharing!

  26. This design is wicked! You most certainly know how to keep
    a reader entertained. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Fantastic job.
    I really enjoyed what you had to say, and more than that,
    how you presented it. Too cool!

  27. Hi there, just became alert to your blog through Google, and found that it’s truly
    informative. I am gonna watch out for brussels. I will be grateful if you continue
    this in future. Many people will be benefited from
    your writing. Cheers!

  28. Very nice post. I just stumbled upon your blog and wanted to say that I have really enjoyed surfing around your blog posts.
    After all I will be subscribing to your feed and I
    hope you write again soon!

  29. Alonzo

    If some one needs expert view concerning blogging and site-building afterward i advise him/her to pay a visit this webpage, Keep up the pleasant work.

  30. Irvin

    Thanks a bunch for sharing this with all folks you really know what you’re
    speaking approximately! Bookmarked. Kindly also discuss
    with my web site =). We can have a link exchange contract among us

  31. Lisette

    Thanks to my father who shared with me on the topic of this web site,
    this web site is in fact awesome.

  32. Lelia

    I love your blog.. very nice colors & theme. Did you create this website yourself
    or did you hire someone to do it for you? Plz reply as I’m looking to create my own blog and would like to find out where u got this from.

    kudos

  33. thefeed

    It’s awesome in favor of me to have a web site, which is useful for my knowledge. thanks admin|

  34. thefeed

    Way cool! Some extremely valid points! I appreciate you writing this article and also the rest of the site is extremely good.|

  35. the feed

    I enjoy what you guys tend to be up too. This kind of clever work and reporting! Keep up the very good works guys I’ve included you guys to my own blogroll.|

  36. feed

    I was very happy to discover this page. I wanted to thank you for ones time for this particularly fantastic read!! I definitely enjoyed every bit of it and I have you saved to fav to look at new things on your site.|

  37. feed

    After looking over a handful of the blog articles on your website, I really appreciate your technique of blogging. I book-marked it to my bookmark website list and will be checking back soon. Please visit my web site as well and let me know how you feel.|

  38. Good post. I learn something new and challenging on blogs I stumbleupon everyday.

    It’s always interesting to read through articles from other writers and practice a little
    something from their web sites.

  39. It is the best time to make some plans for the future and it is time to be happy. I have read this post and if I could I want to suggest you some interesting things or advice. Maybe you can write next articles referring to this article. I wish to read more things about it!|

Leave a Reply