<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://lms.onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=KOTLIN%3A_String</id>
	<title>KOTLIN: String - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://lms.onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=KOTLIN%3A_String"/>
	<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=KOTLIN:_String&amp;action=history"/>
	<updated>2026-04-20T06:39:06Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://lms.onnocenter.or.id/wiki/index.php?title=KOTLIN:_String&amp;diff=65948&amp;oldid=prev</id>
		<title>Unknown user at 03:23, 29 July 2022</title>
		<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=KOTLIN:_String&amp;diff=65948&amp;oldid=prev"/>
		<updated>2022-07-29T03:23:06Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://lms.onnocenter.or.id/wiki/index.php?title=KOTLIN:_String&amp;amp;diff=65948&amp;amp;oldid=65886&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Unknown user</name></author>
	</entry>
	<entry>
		<id>https://lms.onnocenter.or.id/wiki/index.php?title=KOTLIN:_String&amp;diff=65886&amp;oldid=prev</id>
		<title>Unknown user at 04:20, 22 July 2022</title>
		<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=KOTLIN:_String&amp;diff=65886&amp;oldid=prev"/>
		<updated>2022-07-22T04:20:13Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://lms.onnocenter.or.id/wiki/index.php?title=KOTLIN:_String&amp;amp;diff=65886&amp;amp;oldid=65791&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Unknown user</name></author>
	</entry>
	<entry>
		<id>https://lms.onnocenter.or.id/wiki/index.php?title=KOTLIN:_String&amp;diff=65791&amp;oldid=prev</id>
		<title>Unknown user: Created page with &quot;Sumber: https://www.tutorialspoint.com/kotlin/kotlin_strings.htm  The Kotlin String data type is used to store a sequence of characters. String values must be surrounded by do...&quot;</title>
		<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=KOTLIN:_String&amp;diff=65791&amp;oldid=prev"/>
		<updated>2022-07-18T01:25:05Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Sumber: https://www.tutorialspoint.com/kotlin/kotlin_strings.htm  The Kotlin String data type is used to store a sequence of characters. String values must be surrounded by do...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Sumber: https://www.tutorialspoint.com/kotlin/kotlin_strings.htm&lt;br /&gt;
&lt;br /&gt;
The Kotlin String data type is used to store a sequence of characters. String values must be surrounded by double quotes (&amp;quot; &amp;quot;) or triple quote (&amp;quot;&amp;quot;&amp;quot; &amp;quot;&amp;quot;&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
We have two kinds of string available in Kotlin - one is called Escaped String and another is called Raw String.&lt;br /&gt;
&lt;br /&gt;
Escaped string is declared within double quote (&amp;quot; &amp;quot;) and may contain escape characters like &amp;#039;\n&amp;#039;, &amp;#039;\t&amp;#039;, &amp;#039;\b&amp;#039; etc.&lt;br /&gt;
&lt;br /&gt;
Raw string is declared within triple quote (&amp;quot;&amp;quot;&amp;quot; &amp;quot;&amp;quot;&amp;quot;) and may contain multiple lines of text without any escape characters.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
fun main(args: Array&amp;lt;String&amp;gt;) {&lt;br /&gt;
   val escapedString : String  = &amp;quot;I am escaped String!\n&amp;quot;&lt;br /&gt;
   var rawString :String  = &amp;quot;&amp;quot;&amp;quot;This is going to be a&lt;br /&gt;
   multi-line string and will&lt;br /&gt;
   not have any escape sequence&amp;quot;&amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
   print(escapedString)&lt;br /&gt;
   println(rawString)&lt;br /&gt;
}&lt;br /&gt;
When you run the above Kotlin program, it will generate the following output:&lt;br /&gt;
&lt;br /&gt;
I am escaped String!&lt;br /&gt;
This is going to be a&lt;br /&gt;
multi-line string and will&lt;br /&gt;
not have any escape sequence&lt;br /&gt;
This is optional to specify the data type for a String, Kotlin can understand that the a variable is a String because of the given double or tripple quotes.&lt;br /&gt;
&lt;br /&gt;
If you want to create a String variable without assigning the value then you must specify the type while declaring the variable otherwise it will raise an error:&lt;br /&gt;
&lt;br /&gt;
fun main(args: Array&amp;lt;String&amp;gt;) {&lt;br /&gt;
   val name : String&lt;br /&gt;
&lt;br /&gt;
   name = &amp;quot;Zara Ali&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   println(name)&lt;br /&gt;
}&lt;br /&gt;
When you run the above Kotlin program, it will generate the following output:&lt;br /&gt;
&lt;br /&gt;
Zara Ali&lt;br /&gt;
Kotlin String Templates&lt;br /&gt;
Kotlin string templates are pieces of code that are evaluated and whose results are interpolated into the string. A template expression starts with a dollar sign ($) and may consist of either a name or an expression.&lt;br /&gt;
&lt;br /&gt;
fun main(args: Array&amp;lt;String&amp;gt;) {&lt;br /&gt;
   val name : String = &amp;quot;Zara Ali&amp;quot;&lt;br /&gt;
   &lt;br /&gt;
   println(&amp;quot;Name  - $name&amp;quot;)  // Using template with variable name&lt;br /&gt;
   &lt;br /&gt;
   println(&amp;quot;Name length - ${name.length}&amp;quot;)  // Using template with expression.&lt;br /&gt;
}&lt;br /&gt;
When you run the above Kotlin program, it will generate the following output:&lt;br /&gt;
&lt;br /&gt;
Name - Zara Ali&lt;br /&gt;
Name length - 8&lt;br /&gt;
Kotlin String Object&lt;br /&gt;
Kotlin String is an object, which contains a number of properties and functions that can perform certain operations on strings, by writing a dot character (.) after the specific string variable.&lt;br /&gt;
&lt;br /&gt;
We will see some of the important properties and functions in this chapter, remaining you can find in official documentation of Kotlin latest version.&lt;br /&gt;
&lt;br /&gt;
Kotlin String Indexes&lt;br /&gt;
Kotlin String can be treated as a sequence of characters or you can say String is an array of characters. You can access its element by specifying the index of the element using a square brackets.&lt;br /&gt;
&lt;br /&gt;
String indexes start with 0, so if you want to access 4th element of the string then you should specify index as 3 to access the 4th element.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
fun main(args: Array&amp;lt;String&amp;gt;) {&lt;br /&gt;
   val name : String = &amp;quot;Zara Ali&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   println(name[3])&lt;br /&gt;
   println(name[5])&lt;br /&gt;
}&lt;br /&gt;
When you run the above Kotlin program, it will generate the following output:&lt;br /&gt;
&lt;br /&gt;
a&lt;br /&gt;
A&lt;br /&gt;
Kotlin String Length&lt;br /&gt;
We can use length property of Kotlin string to find out its length.&lt;br /&gt;
&lt;br /&gt;
Kotlin function count() also returns the length of a given string.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
fun main(args: Array&amp;lt;String&amp;gt;) {&lt;br /&gt;
   val name : String = &amp;quot;Zara Ali&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   println(&amp;quot;The length of name :&amp;quot; + name.length)&lt;br /&gt;
   println(&amp;quot;The length of name :&amp;quot; + name.count())&lt;br /&gt;
      &lt;br /&gt;
}&lt;br /&gt;
When you run the above Kotlin program, it will generate the following output:&lt;br /&gt;
&lt;br /&gt;
The length of name :8&lt;br /&gt;
The length of name :8&lt;br /&gt;
Kotlin String Last Index&lt;br /&gt;
We can use lastIndex property of Kotlin string to find out the index of the last character in the char sequence. If a string is empty then it returns a -1.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
fun main(args: Array&amp;lt;String&amp;gt;) {&lt;br /&gt;
   val name : String = &amp;quot;Zara Ali&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   println(&amp;quot;The index of last character in name :&amp;quot; + name.lastIndex)&lt;br /&gt;
}&lt;br /&gt;
When you run the above Kotlin program, it will generate the following output:&lt;br /&gt;
&lt;br /&gt;
The index of last character in name :7&lt;br /&gt;
Changing Case of Strings&lt;br /&gt;
Kotlin provides toUpperCase() and toLowerCase() functions to convert a string into upper case and lower case respectively.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
fun main(args: Array&amp;lt;String&amp;gt;) {&lt;br /&gt;
   val name : String = &amp;quot;Zara Ali&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   println(&amp;quot;Upper case of name :&amp;quot; + name.toUpperCase())&lt;br /&gt;
   println(&amp;quot;Lower case of name :&amp;quot; + name.toLowerCase())&lt;br /&gt;
}&lt;br /&gt;
When you run the above Kotlin program, it will generate the following output:&lt;br /&gt;
&lt;br /&gt;
Upper case of name :ZARA ALI&lt;br /&gt;
Lower case of name :zara ali&lt;br /&gt;
Kotlin String Concatenation&lt;br /&gt;
We can use either + operator to concatenate two strings, or we can also use plus() function to concatenate two strings.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
fun main(args: Array&amp;lt;String&amp;gt;) {&lt;br /&gt;
   var firstName : String = &amp;quot;Zara &amp;quot;&lt;br /&gt;
   var lastName : String = &amp;quot;Ali&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   println(&amp;quot;Full Name :&amp;quot; + firstName + lastName)&lt;br /&gt;
   &lt;br /&gt;
   println(&amp;quot;Full Name :&amp;quot; + firstName.plus(lastName) )&lt;br /&gt;
}&lt;br /&gt;
When you run the above Kotlin program, it will generate the following output:&lt;br /&gt;
&lt;br /&gt;
Full Name :Zara Ali&lt;br /&gt;
Full Name :Zara Ali&lt;br /&gt;
Trim Characters from a String&lt;br /&gt;
We can remove first few or last few characters from a string using drop() or dropLast() functions.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
fun main(args: Array&amp;lt;String&amp;gt;) {&lt;br /&gt;
   var name : String = &amp;quot;Zara Ali&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   println(&amp;quot;Remove first two characters from name : &amp;quot; + name.drop(2))&lt;br /&gt;
   &lt;br /&gt;
   println(&amp;quot;Remove last two characters from name : &amp;quot; + name.dropLast(2))&lt;br /&gt;
}&lt;br /&gt;
When you run the above Kotlin program, it will generate the following output:&lt;br /&gt;
&lt;br /&gt;
Remove first two characters from name : ra Ali&lt;br /&gt;
Remove last two characters from name : Zara A&lt;br /&gt;
Quotes Inside a String&lt;br /&gt;
To use quotes inside a string, use single quotes (&amp;#039;):&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
fun main(args: Array&amp;lt;String&amp;gt;) {&lt;br /&gt;
   var str1 : String = &amp;quot;That&amp;#039;s it&amp;quot;&lt;br /&gt;
   var str2 : String = &amp;quot;It&amp;#039;s OK&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   println(&amp;quot;str1 : &amp;quot; + str1)&lt;br /&gt;
   println(&amp;quot;str2 : &amp;quot; + str2)&lt;br /&gt;
}&lt;br /&gt;
When you run the above Kotlin program, it will generate the following output:&lt;br /&gt;
&lt;br /&gt;
str1 : That&amp;#039;s it&lt;br /&gt;
str2 : It&amp;#039;s OK&lt;br /&gt;
Finding a String inside a String&lt;br /&gt;
Kotlin provides indexOf() function to find out a text inside a string. This function returns the index of the first occurrence of a specified text in a string&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
fun main(args: Array&amp;lt;String&amp;gt;) {&lt;br /&gt;
   var str : String = &amp;quot;Meditation and Yoga are synonymous with India&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   println(&amp;quot;Index of Yoga in the string - &amp;quot; + str.indexOf(&amp;quot;Yoga&amp;quot;))&lt;br /&gt;
}&lt;br /&gt;
When you run the above Kotlin program, it will generate the following output:&lt;br /&gt;
&lt;br /&gt;
Index of Yoga in the string - 15&lt;br /&gt;
Comparing Two Strings&lt;br /&gt;
Kotlin provides compareTo() function to compare two strings. This function returns 0 if two strings are equal otherwise it will return 1.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
fun main(args: Array&amp;lt;String&amp;gt;) {&lt;br /&gt;
   var str1 : String = &amp;quot;Apple&amp;quot;&lt;br /&gt;
   var str2 : String = &amp;quot;Apple&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   println(str1.compareTo(str2))&lt;br /&gt;
}&lt;br /&gt;
When you run the above Kotlin program, it will generate the following output:&lt;br /&gt;
&lt;br /&gt;
0&lt;br /&gt;
Kotlin getOrNull() function&lt;br /&gt;
Kotlin getOrNull() function returns a character at the given index or null if the index is out of bounds of this char sequence.&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
fun main(args: Array&amp;lt;String&amp;gt;) {&lt;br /&gt;
   var name : String = &amp;quot;Zara&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   println(name.getOrNull(0))&lt;br /&gt;
   println(name.getOrNull(2))&lt;br /&gt;
   println(name.getOrNull(100))&lt;br /&gt;
}&lt;br /&gt;
When you run the above Kotlin program, it will generate the following output:&lt;br /&gt;
&lt;br /&gt;
Z&lt;br /&gt;
r&lt;br /&gt;
null&lt;br /&gt;
Kotlin toString() function&lt;br /&gt;
Kotlin toString() function returns a string representation of the object..&lt;br /&gt;
&lt;br /&gt;
Example&lt;br /&gt;
fun main(args: Array&amp;lt;String&amp;gt;) {&lt;br /&gt;
   var name : String = &amp;quot;Zara Ali&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   println(name.toString())&lt;br /&gt;
}&lt;br /&gt;
When you run the above Kotlin program, it will generate the following output:&lt;br /&gt;
&lt;br /&gt;
Zara Ali&lt;br /&gt;
Quiz Time (Interview &amp;amp; Exams Preparation)&lt;br /&gt;
Q 1 - Which of the following is true about Control Flow Statement?&lt;br /&gt;
&lt;br /&gt;
A - Control flow controls the execution of the program&lt;br /&gt;
&lt;br /&gt;
B - Loops and Decision Statements are part of control flow&lt;br /&gt;
&lt;br /&gt;
C - Control flow is an essential part of modern programming languages&lt;br /&gt;
&lt;br /&gt;
D - All of the above&lt;br /&gt;
&lt;br /&gt;
Q 2 - Which of the following is a control flow statement in Kotlin?&lt;br /&gt;
&lt;br /&gt;
A - String&lt;br /&gt;
&lt;br /&gt;
B - Fun&lt;br /&gt;
&lt;br /&gt;
C - When&lt;br /&gt;
&lt;br /&gt;
D - None of the above&lt;br /&gt;
&lt;br /&gt;
Q 3 - If we do not have control flow statements, then it will be almost impossible to write a computer program?&lt;br /&gt;
&lt;br /&gt;
A - True&lt;br /&gt;
&lt;br /&gt;
B - False&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Referensi==&lt;br /&gt;
&lt;br /&gt;
* https://www.tutorialspoint.com/kotlin/kotlin_strings.htm&lt;/div&gt;</summary>
		<author><name>Unknown user</name></author>
	</entry>
</feed>