ApexSensei

Drills › Write Apex

Count open cases

Write Apex · Beginner · 5 min · Runs in the browser, no org needed · Free

Scenario. A short script should remember that four cases are open. Store that count as a number.

Store how many cases are open as a whole number, not as text.

What you will learn

An Integer is a whole number. Write the digits with no quotes. Text stays in single quotes, so '4' is text and 4 is a number.

Integer openCases = 4;

Gotcha. Quotes turn a number into text. Later math needs the bare number.

The task

Set the open-case count to 4, as a number.

Examples:

  • Integer openCases = 4; → openCases holds the number 4
  • Integer openCases = '4'; → that is text, not a number

Requirements:

  1. Set openCases to the number 4.
  2. Keep the Integer type and the variable name.
  3. Do not put quotes around 4.
  4. Leave companyName as the quoted company name.

Starter code

String companyName = 'RidgePoint Capital';
Integer openCases = null;
String city = 'Denver';
Boolean active = true;

When it passes

`openCases` is the Integer 4, with no quotes, and the company name stays text.

Try this drill free

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

‹ Store the company name · Build the account label ›