

Additional documentation is located online in the official Java documentation. There are more string methods than those linked from this page. In view of this, option A is incorrect because the text block opening delimiter ( ''') has. It’s permitted to have spaces or tabs before the actual newline character, but nothing else is permitted. In the test shown here, the split () of the String. A Java text block starts with triple (three) double quote marks, and that character sequence must form the end of that line of source code. This just means that whatever is in between \Q and \E would be escaped. \Q indicates that all characters up to \E needs to be escaped and \E means we need to end the escaping that was started with \Q. For instance: ('And then Jim said, \'Who's at the door\'') It isn’t necessary to escape the double quote inside single quotes. Alternatively, we can use \Q and \E to escape the special character. Because backslash is the escape character, to include a single backslash within a String, you must use two consecutive backslashes, as in: \\ Double quotes being for String, you have to use a double quote escape sequence ( \') inside strings where it would otherwise terminate the string. Other escape sequences include \t for the tab character and \n for new line. Because strings must be written within quotes, Java will misunderstand this string, and generate an error: String txt 'We are the so-called 'Vikings' from the north.' The solution to avoid this problem, is to use the backslash escape character. The escape character for SOQL is the backslash (\) character. You can escape new lines, carriage returns, tabs, quotes, and more.

The Java compiler interprets these characters. (See the third example above.) This is known as an escape sequence. SOQL defines several escape sequences that are valid in queries so that you can include special characters in your queries. Remember that escape characters must be enclosed in quotation marks (). (The troubleshooting reference has a longer explanation.)īecause a String is defined between double quotation marks, to include such marks within the String itself you must use the \ (backslash) character. Using the equals() method will ensure that the actual contents are compared. A String is an Object, so comparing them with the = operator only compares whether both Strings are stored in the same memory location. To compare the contents of two Strings, use the equals() method, as in if (a.equals(b)), instead of if (a = b). Strings are always defined inside double quotes ( "Abc"), and characters are always defined inside single quotes ( 'A'). The class String includes methods for examining individual characters, comparing strings, searching strings, extracting parts of strings, and for converting an entire string uppercase and lowercase.
