object Program {
def main(args: Array[String]): Unit = {
val source =
"bird cat frog"
// Search for parts of the string.
val birdIndex = source.indexOf(
"bird")
val catIndex = source.indexOf(
"cat")
val frogIndex = source.indexOf(
"frog")
// This string is not found, so we get -1.
val noIndex = source.indexOf(
"???")
// Print out all the variables.
println(source)
println(birdIndex)
println(catIndex)
println(frogIndex)
println(noIndex)
}
}
bird cat frog
0
5
9
-1