Blog Blog Posts Business Management Process Analysis

What is Apex String Class in the Salesforce

Salesforce CRM helps thousands of companies around the world discover new opportunities, drive marketing campaigns, manage and use customer data, and improve communication (internal and external). Ultimately, it helps them improve their decision-making skills and fuel stronger business growth. In Salesforce there is an important concept which deals with many predefined methods to make the work easier in Salesforce. This is known as Apex String Methods.

String as we all know means string data type which deals with a set of characters with no specified limit.

Watch the video and learn all about Salesforce

 

What is Apex?

Apex is a proprietary language developed by Salesforce.com. Formally defined, Apex is a strongly typed, object-oriented programming language that enables developers to combine Force.com and API calls to execute transactions and stream instructions on the Force.com platform server.

It has a Java-like syntax, and its behavior is similar to a stored procedure in a database. It allows developers to add business logic to most system events, including button clicks, link record updates, and Visualforce pages.

Apex has a performance edition, unlimited edition, enterprise edition, and developer edition.

Let’s understand what is Apex used for:

Apex includes an application programming interface (API) that developers can use to access user data on Salesforce.com. This API enables developers to use common SaaS components such as web widgets or a multi-user database without having to traditionally develop much of the infrastructure.

Get to know more about Salesforce Data Type from our blog- Salesforce Data Types and Field Types.

 

What is Apex String Class Salesforce?

String Class Salesforce is basically a class variable that consists of various Apex String Methods and these particular String methods Salesforce allows Alt-textusers to perform multiple operations in different strings. So when these String Methods combine together they make a string class in Salesforce.

 

List of Apex String Methods Salesforce-

There are different types of Apex String Methods in Apex String Class that allow the users to deal with various pre-defined methods. These pre-defined methods are apex string methods Salesforce.

Some of the popular Apex String Methods are listed below-

String myProduct1 = ‘Salesforce';
String myProduct2 = 'Intllipaat Salesfoce Course';
Boolean result = myProductName2.contains(myProduct1);
System.debug('Output will be true as it contains the String and
Output is:'+result);
	
String str = 'Hello Intellipaat.';
System.assertEquals(937, str.charAt(0));

Note– The values must not be NULL, also, it is case sensitive.

String string1 = 'Intellipaat';
String string2 = 'Intellipaat';
Boolean result = string2.equals(string1);
System.debug('Value of Result will be true as they are same and Result is:'+result);

Note– this method is not case-sensitive.

        String string1 = 'intellipaat';
	String string2 = 'INTELLIPAAT';
	Boolean result =
	myString1.equalsIgnoreCase(string2);
	System.assertEquals(result, true);

Note- This method is case-sensitive. If the same string appears but the case is different, this method will not work as a string method in Salesforce

	String s1 = 'Salesforce and force.com';
	String s2 =
	  s1.remove('force');
	System.assertEquals(
	  'Sales and .com', s2);
	String myString1 = 'abcde';
	String myString2 = 'cd';
	Integer result = myString1.indexOf(mystring2);
	System.assertEquals(2, result);

Note- Method is not case sensitive.

	String s1 = 'Salesforce and Intellipaat';
	System.assert(s1.startsWith('Salesforce'));
//Return true
String s1 = 'INTELLIPAAT';
Boolean b1 = s1.isAllUpperCase()
//Return true
String s1 = 'intellipaat';
Boolean b1 = s1.isAllLowerCase()

Check out our blog on Salesforce Admin Interview Questions and Answers and ace your interview in your job interview.

Become a Salesforce Administrator and App Builder
 

What are access modifiers in Salesforce?

There are various access modifiers in Salesforce which provide data security and maintain data integrity in an enterprise. The access modifiers provide different access to different people according to their job roles. The access specifiers in Salesforce are-

Example of public and private access specifiers in Salesforce

	
// private variable s1
	private string s1 = '1';
	 
	// public method sales()
	public string sales() {
	  ...
	}

Get your queries cleared on Intellipaat’s Salesforce community!

The post What is Apex String Class in the Salesforce appeared first on Intellipaat Blog.

Blog: Intellipaat - Blog

Leave a Comment

Get the BPI Web Feed

Using the HTML code below, you can display this Business Process Incubator page content with the current filter and sorting inside your web site for FREE.

Copy/Paste this code in your website html code:

<iframe src="https://www.businessprocessincubator.com/content/what-is-apex-string-class-in-the-salesforce/?feed=html" frameborder="0" scrolling="auto" width="100%" height="700">

Customizing your BPI Web Feed

You can click on the Get the BPI Web Feed link on any of our page to create the best possible feed for your site. Here are a few tips to customize your BPI Web Feed.

Customizing the Content Filter
On any page, you can add filter criteria using the MORE FILTERS interface:

Customizing the Content Filter

Customizing the Content Sorting
Clicking on the sorting options will also change the way your BPI Web Feed will be ordered on your site:

Get the BPI Web Feed

Some integration examples

BPMN.org

XPDL.org

×