object Scala_String {
def test(str1: String, str2: String): Boolean = {
str1.contains(str2)
}
def main(args: Array[String]): Unit = {
var str1 = "Scala Exercises and Python Exercises";
var str2 = "and";
println("Original String: " + str1);
println("Specified sequence of char values: " + str2);
println("Test if the said string contains the specified sequence of char values!")
println(test(str1, str2))
str1 = "Scala Exercises and PHP Exercises";
str2 = "Python";
println("Original String: " + str1);
println("Specified sequence of char values: " + str2);
println("Test if the said string contains the specified sequence of char values!")
println(test(str1, str2))
}
}
Sample Output:
Original String: Scala Exercises and Python Exercises
Specified sequence of char values: and
Test if the said string contains the specified sequence of char values!
true
Original String: Scala Exercises and PHP Exercises
Specified sequence of char values: Python
Test if the said string contains the specified sequence of char values!
false
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer