Compares string in Kotlin are possible in the following ways :
1. Using “==” operator :
You can use ah operator for comparison of two string. In Kotlin
== operator is used.
2. Using compareTo() extension function
Syntax of compareTo() function is given below :
fun String.compareTo(
other: String,
ignoreCase: Boolean = false
): Int
Another code example
fun main(args: Array & lt; String & gt;) {
val x: String = "Kotlin is simple"
val y: String = "Kotlin language is" + " easy"
if (x == y) {
println(" x and y are similar.")
} else {
println(" x and y are not similar.")
}
}