The String data type in Apex is used to represent a sequence of characters. Strings are enclosed in single quotes (').
// Declaring and initializing a String
String firstName = 'Jane';
String lastName = 'Doe';
// Concatenating Strings
String fullName = firstName + ' ' + lastName;
System.debug('Full name: ' + fullName); // Outputs: Full name: Jane Doe
Sign up to track your progress, earn points, and compete with others. Your solutions will be saved automatically.
Create account