To compare two strings in Kotlin, you can use the ==
operator directly.
In this example,
str1
and str2
with different values.==
operator.true
if the strings are equal, and false
otherwise.// Comparison of Strings in Kotlin
fun main() {
val str1 = "Hello"
val str2 = "hello"
val result = str1 == str2
println("Strings are equal: $result")
}
Strings are equal: false
In this tutorial, we learned How to Compare Two Strings in Kotlin language with well detailed examples.