In this program the character x is moved to the last
public class MoveStringAtLast {
public static void main(String[] args) {
StringBuffer str=new StringBuffer("Hi this is xmas context");
System.out.println("The initial String is: "+str);
for(int i=0;i<str.length();i++)
{
if(str.charAt(i)=='x')
{
str.deleteCharAt(i);
str.append('x');
}
}
System.out.println("The Resulting String is: "+str);
}
}
public class MoveStringAtLast {
public static void main(String[] args) {
StringBuffer str=new StringBuffer("Hi this is xmas context");
System.out.println("The initial String is: "+str);
for(int i=0;i<str.length();i++)
{
if(str.charAt(i)=='x')
{
str.deleteCharAt(i);
str.append('x');
}
}
System.out.println("The Resulting String is: "+str);
}
}
0 comments:
Post a Comment