OneCompiler

Remove the occurrence of second string

160

Q3 Write a program to read two strings. Remove the occurrence of second string in first string. in scala program

object RemoveString {

def main(args: Array[String])
{
val str1 = "Hello World"
val str2 = "Hello"

println("String 1: "+str1) 
println("String 2: "+str2) 

val newStr = str1.replace(str2,"") 
println("New String: "+newStr) 

}
}