與任何其他編程語言一樣,Apex中的字符串是沒有字符限制的任何字符集。
示例:
String companyName = 'Abc International'; System.debug('Value companyName variable'+companyName);
public Boolean contains(String substring)
String myProductName1 = 'HCL'; String myProductName2 = 'NAHCL'; Boolean result = myProductName2.contains(myProductName1); System.debug('O/p will be true as it contains the String and Output is: '+result );
public Boolean equals(Object string)
String myString1 = 'MyString'; String myString2 = 'MyString'; Boolean result = myString2.equals(myString1); System.debug('Value of Result will be true as they are same and Result is:'+result);
public Boolean equalsIgnoreCase(String stringtoCompare)
String myString1 = 'MySTRING'; String myString2 = 'MyString'; Boolean result = myString2.equalsIgnoreCase(myString1); System.debug('Value of Result will be true as they are same and Result is:'+result);
public String remove(String stringToRemove)
String myString1 = 'This Is MyString Example'; String stringToRemove = 'MyString'; String result = myString1.remove(stringToRemove); System.debug('Value of Result will be 'This Is Example' as we have removed the MyString and Result is :'+result);
public String removeEndIgnoreCase(String stringToRemove)
String myString1 = 'This Is MyString EXAMPLE'; String stringToRemove = 'Example'; String result = myString1.removeEndIgnoreCase(stringToRemove); System.debug('Value of Result will be 'This Is MyString' as we have removed the 'Example' and Result is :'+result);
public Boolean startsWith(String prefix)
String myString1 = 'This Is MyString EXAMPLE'; String prefix = 'This'; Boolean result = myString1.startsWith(prefix); System.debug(' This will return true as our String starts with string 'This' and the Result is :'+result);
更多建議: