Public class stringdemo {
Public static void main (string ARGs []) {
String S1 = "this is my original string ";
String SD = "original ";
If (s1.startswith (SD ))
// Startswith () method to determine whether string S1 starts from string SD
S1 = s1.substring (SD. Length ());
Else
If (s1.endswith (SD ))
// Use the endwith () method to determine whether string S1 ends with string SD.
S1 = s1.substring (0, s1.length ()-SD. Length ());
Else
{
Int Index = s1.indexof (SD );
// Indexof () indicates the first occurrence of a character or substring. The index here is equal to 11.
If (index! =-1)
{
String S2 = s1.substring (0, index );
// Starts from the first character of string S1 and takes the index character
String S3 = s1.substring (index + SD. Length ());
// Obtain the string following the 19th characters of string S1
S1 = S2 + S3;
}
Else
System. Out. println ("String/" "+ SD +"/"not found ");
}
System. Out. println (S1 );
}
}