
You are given two strings S1 and S2,Delete from S2 all those characters which occur in s1 also and create a clean S2 with the relevant characters deleted..write a pgm for this..pls send as soon as possible..
Thank you..

package string;
public class StringExample3 {
/**
*
* You are given two strings S1 and S2,Delete from S2 all those
* characters which occur in s1 also and create a clean S2 with
* the relevant characters deleted..write a pgm for this..pls send
* as soon as possible..
* @param args
*/
public static void main(String[] args) {
String s1 = "Shiv";
String s2 = "Shri";
String occuredChars = "";
String nonOccuredChars = "";
for(int i = 0; i< s2.length(); i++){
char c = s2.charAt(i);
if(s1.contains(c+"")){
occuredChars = occuredChars + c;
}else{
nonOccuredChars = nonOccuredChars + c;
}
}
System.out.println("occuredChars in S2:"+occuredChars);
System.out.println("nonOccuredChars S2:"+nonOccuredChars);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.