Delete s1 From s2 String

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

public class Delete_s1_to_s2 {

public static void main(String[] args)


// TODO Auto-generated method stub

String s="bdf";
String s1="abe ad gf dck";
String s2=" ";

char c[]=s.toCharArray();
char c1[]=s1.toCharArray();

//System.out.print(s1+"\n");
for(int i=0;i<c.length;i++){
char ch=s.charAt(i);
for(int j=0;j<c1.length;j++){
char ch1 = s1.charAt(j);
if(ch==ch1)
{
c1[j]=' ';
//System.out.print(ch1);
}
}
}

System.out.println("String 1 is "+ s);


System.out.println("String 2 is "+ s1);
System.out.println("After Removing String 1 char from
String 2 ");

for(int i=0;i<c1.length;i++){
System.out.print(c1[i]);
}
}
}

You might also like