ApexSensei

Drills › Write Apex

Hello, ApexSensei

Write Apex · Beginner · 5 min · Runs in your Salesforce Developer org · Free

Scenario. Confirm that your Salesforce connection can compile, execute, and return one clear log line.

Run your first Apex statement in Salesforce and read its labeled debug output.

What you will learn

Apex runs on Salesforce servers, so developers inspect values with System.debug(). Text uses single quotes and every statement ends with a semicolon.

String status = 'Ready';
System.debug('Status: ' + status);

Gotcha. Debug output helps developers; Salesforce users do not see it.

The task

Set the greeting and print it with the label Greeting:.

Examples:

  • greeting Hello, ApexSensei! → Greeting: Hello, ApexSensei!
  • greeting Welcome → Greeting: Welcome

Requirements:

  1. Set greeting to Hello, ApexSensei!.
  2. Print Greeting: plus the variable with System.debug.
  3. Build the line from the greeting variable. Don't type the whole line as one piece of text.

Starter code

String greeting = null;

When it passes

The log shows one debug line: `Greeting: Hello, ApexSensei!`

Try this drill free

You write the Apex yourself. ApexSensei runs it and tells you what passed and what did not.

‹ Comments that survive review · Quick win: double a number ›