I have written a program to remove the characters from the second string which are present in the first string.
I had Written a code for the above mentioned Problem Can someone Suggest Changes to make It efficient
class StrAssiQ5
{
public static String Removal(String s,String s1)
{
StringBuffer a=new StringBuffer();;
for(int i=0; i<s.length(); i++)
{int count=0;
for(int j=0; j<s1.length(); j++)
{
if(s.charAt(i)==s1.charAt(j))
{
count++;
//a.append(Character.toString(s.charAt(i)));
}
}
if (count==0)
a.append(Character.toString(s.charAt(i)));
}
return a.toString();
}
public static void main(String [] args)
{
String s="Gaurav";
String s1="Juneja";
s=StrAssiQ5.Removal(s,s1);
System.out.println(s);
}
}
output is : Grv