code to delete the all occurances in of character in original string


import java.util.Scanner;

public class Strerase {
public static void main(String[] args) {
String s1, s2;
Scanner s = new Scanner(System.in);
System.out.println("enter First String");
s1 = s.nextLine();
System.out.println("enter second string which u want to erase from string1");
s2 = s.nextLine();

    char str1[] = s1.toCharArray();
    char str2[] = s2.toCharArray();
    char str3[] = new char[str1.length];
    for (int i = 0; i < str1.length; i++) {
        for (int j = 0; j < str2.length; j++) {
            if (str1[i] != str2[j]) {
                str3[i] = str1[i];
            }
        }
    }

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

}

}