Beginner 15 min read

A First Look at Non-Primitive Types

By the end of this lesson, you'll be able to:

  • Explain the difference between primitive and non-primitive types at a conceptual level
  • Name two non-primitive types you will meet soon
  • Explain why this distinction will matter once you reach classes and collections

Prerequisites: "Salesforce Record IDs: the Id Type"

What makes a type 'primitive'

A primitive type holds exactly one simple value — a number, a bit of text, true/false. Every type in this module so far has been primitive. A non-primitive type holds something more structured: a collection of values, a custom-built object, a whole record's worth of fields.

Two you'll meet very soon

  • Lists (Module "Collections: Lists") — an ordered group of values, like a shopping list, not just one number.
  • sObjects (Module "Understanding Salesforce Data in Apex") — an in-memory representation of an actual Salesforce record, with all its fields.

You don't need to understand either yet — just recognize, going forward, that "type" in Apex means more than just "a single number or word."

Why this distinction matters later

Primitive variables are copied by value — assigning one to another makes a fully independent copy. Non-primitive types (once you meet them properly) behave differently in ways that trip up a lot of beginners if the distinction was never introduced. This lesson exists purely so that distinction doesn't come as a surprise later.

Exercise

In your own words, write one sentence explaining the difference between a primitive and a non-primitive type, without looking back at this lesson.

Show hint

Focus on 'one simple value' vs 'a structured collection of values.'

A First Look at Non-Primitive Types Quiz

1. Which of these is a primitive type?

2. A List is an example of a non-primitive type.

Log in to submit the quiz and save your score.

My Notes

Log in to keep private notes on this lesson.

Questions about this lesson

No questions yet — be the first to ask.

Log in to ask a question about this lesson.

Summary

Every type you've met so far — Integer, String, Boolean, Date, Id — is a primitive: a single, simple value. Non-primitive types hold more complex, structured data, and this lesson previews what's coming without going deep yet.