How to remove specific character from an String in Java.



public class RemoveCharacterFromArray
{
    public static void main(String args[])
    {
        String s = "Umesh kumar kushwaha";
        String r[] = s.split("s|h");
        String res = "";
        for (String m : r) 
        {
            res = res + m;
        }
        System.out.println(res);
    }
}

Output:

Ume kumar kuwaa

BUILD SUCCESSFUL (total time: 0 seconds)



No comments:

Post a Comment