Skip to main content

Featured

What is Coroutine in Android?

Coroutines are available for the Kotlin language. Coroutines are simply cooperative functions.   Our Android applications often have multiple concurrent and interdependent functionalities. We provide instructions to the system through code, also known as a program, to perform a set of sequential instructions.  During the execution of these instructions, a specific instruction may take longer than expected, causing the next line of code to wait until the previous line of code has completed its execution. This scenario is known as blocking program execution. To avoid blocking program execution, the code must be executed on a separate thread. A thread is a single sequential flow of control. However, creating and handling multiple threads can be difficult and expensive in terms of OS operations and memory usage. To address this issue, we can use Coroutines in Kotlin. Coroutines are cooperative functions that are executed on threads as needed in a cooperative manner. They help manage long-r

Kotlin : Characters and Strings

In this post will talk about 2 important datatype of Kotlin that are Characters and String. These datatype are often used in Kotlin


Character Datatype in Kotlin


Character is one of the datatype in kotlin. As name suggest with this datatype you can store characters in Kotlin.


var firstAlphabet : Char = A

In above example ‘Char’ is a datatype for character. It can store a single character value. Character variable stored within

String Datatype in Kotlin 


A set or group of character is known as String. It is used for storing the text value.


var sampleString = Hello World
// specify the data type of string like this
var anotherString : String = Hello 

String values are presented between “ “ (double quotes). With this kotlin can get idea that user want to store a string type value on this particular variable.


If you don’t want to assign the value of string variable at the time of assignment then you need to specify the datatype of variable like this :


var stringWithoutValue:String

stringWithoutValue = Some value

So this a basic details about character and string datatype in Kotlin.

Comments

Popular Posts