Code to compare two strings in Kotlin?

All QuestionsCategory: KotlinCode to compare two strings in Kotlin?
chetan shidling asked 4 years ago

I need short information.

1 Answers
chetan shidling answered 4 years ago

Here is the code to compare two strings.
 
fun main(args:Array <String>){
var string1 : String = “Chetan”
var string2 : String = “Chetan”

if(string1.equals(string2))
println(“Same”)
else
println(“Not same”)
}
 
Output:
 
Same
 
fun main(args:Array <String>){
var string1 : String = “chetan”
var string2 : String = “Chetan”

if(string1.equals(string2))
println(“Same”)
else
println(“Not same”)
}
 
Output:
 

Not same