In this program the same characters are seperated by *
public class IDString {
public static void main(String[] args) {
StringBuffer str1=new StringBuffer("hii my naame iisss");
System.out.println("Initially the string is: "+str1);
for(int i=0;i<str1.length()-1;i++)
{
if(str1.charAt(i)==str1.charAt(i+1))
{
str1.insert(i+1,'*');
}
}
System.out.println("String is :"+str1);
}
}
public class IDString {
public static void main(String[] args) {
StringBuffer str1=new StringBuffer("hii my naame iisss");
System.out.println("Initially the string is: "+str1);
for(int i=0;i<str1.length()-1;i++)
{
if(str1.charAt(i)==str1.charAt(i+1))
{
str1.insert(i+1,'*');
}
}
System.out.println("String is :"+str1);
}
}
0 comments:
Post a Comment