'How to remove multiple alphabetical characters from a String and Store them in a Single String variable in Java


public class Remove {

public static void main(String arg[]) {

    int i;
    int j;
    String myString = "i love learning coding 2011";
    String argg = "ol1";
    String rdup = "";

    for (i = 0; i < argg.length(); i++) {
        for (j = 0; j < myString.length(); j++) {
            if (argg.charAt(i) == myString.charAt(j)) {
                myString.replace(myString.charAt(j), ' ');
            } else {
                rdup += myString.charAt(j);
            }
        }
    }
    System.out.println(rdup);
    System.out.println();
}

Input: "i love learning coding 2011" output: I ve earning cding 2011 --->



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source