The purpose of extension functions is to add new functions to the existing class which means it can simply add functions to the class without declearing it inside the class. The new function actually behaves like static. It can become part of your own class (like Student) or can become part of the predefined class(like […]
Learn about Default function in Kotlin with suitable example here
In Java there is no concept of Default function .If you want to use your default function, which is already used in Kotlin,in your java you need to write @JvmOverloads for interoperability. Let see an example to make out- Ex- @file:JvmName(“MyCustomKotlinName”) fun main(args : Array<String>){ var result = findVolumn(2, 3) //height value has no need […]
How to use “when” expression in Kotlin programming language?
”when” is nothing but ‘Switch’ statement in C and Java language.There is also default case but this is expressed with else in When block.There is no break statement.We can attach multiple cases as well as a range(like 1…20) in one case.Also we can attach multiple condition in one case.The appropriate example is written below- fun […]
How we can declare mutable and immutable string in Kotlin?
In Kotlin whatever value you define here that determines the data types of the variable. Suppose (var myNumber =10),that automatically becomes integer value. Similarly, you can write the datatypes of the variable (var myString: String). In case of the mutable string, you can modify string at any point of time. Example of mutable & […]
Why Kotlin is used and what is SINGLETON in Kotlin?
Kotlin is a statically typed language. It is also known as JVM language because Kotlin needs Java Virtual Machine (JVM) to execute its bytecode. Some exceptional features making it different than others i) Since it is JVM language so it’s fully interoperable on Java language. Since it is new in the market so it’s developed […]