Code for Program to show an example of modifying String objects in Java
publicclass JAVA_053
{
publicstaticvoid main(String[] args)
{
String Str="To be or not to be";
System.out.println("The Original String is : " + Str);
Str=Str.replace(' ','%');
System.out.println("The Replaced String is : " + Str);
Str=" This is a String. ";
System.out.println("\nThe Original String is : " + Str);
Str=Str.trim( );
System.out.println("The Trimed String is : " + Str);
}
}