Subscribe for notification
Categories: Android Tutorial

Working with Strings in Kotlin & Building It

A string is a basic data type in a programming language. In Kotlin, the String class represents character strings. Kotlin string literals are implemented as instances of this class. Kotlin uses double quotes to create string literals. Kotlin has a rich API for working with strings. It contains plenty of methods for various string operations. Kotlin/Java strings are immutable, which means that all modification operations create new string instead of modifying a string in-place.

Kotlin String
Strings are a sequence of characters. For example, “Hello there!” is a string literal.In Kotlin, all strings are objects of String class. Meaning, string literals such as “Hello there!” are implemented as instances of this class.

Here, myString is a variable of type String. You can declare variable of type String and specify its type in one statement, and initialize the variable in another statement later in the program.

As we know, String objects are immutable. With each concatenation using the + operator or plus() method, we get a new String object. In contrast, to avoid unnecessary String object creation, we can use a StringBuilder.Hence, StringBuilder creates a single internal buffer that contains the final string.

Therefore, StringBuilder is more efficient when concatenating a large number of strings.Kotlin also has a feature called String templates. String templates contain expressions that get evaluated to build a String.String template expressions start with a dollar sign followed by variable’s name.


SyncSaS Technologies is specialized in creating and designing customized software. We have our own team that will be in charge of developing your softwares.

Published by

Recent Posts

Adsense Updated Dashboard

Changes in Adsense Dashboard Recently you might have seen few changes in Adsense dashboard, these…

3 weeks ago

Guide Book For Google Adsense

With my experience in working as AdSense publisher, I have written many articles, tutorials for…

3 weeks ago

How to manage Google Adsense to get High CPC

Manage Adsense for High CPC CPC (Cost per click) in simple words the CPC is…

3 weeks ago

Google Adsense Introduce page level ads

If you are already the publisher of Google Adsense account then now its time to…

3 weeks ago