fun main() {
// Define the string we want to search in
val s = "kotlinlang"
// Check for a character using contains()
val hasK = s.contains('k') // true
val hasZ = s.contains('z') // false
// Print the raw boolean results
println(hasK)
println(hasZ)
// Conditional check
if (s.contains('k')) {
println("exists")
} else {
println("not exists")
}
}
/*
run:
true
false
exists
*/