| [ Web Proxy ] |
| Viewing: https://raw.githubusercontent.com/devdeepak06/Java_Fundamentals/main/RemoveCharacter.java | [Back] [Original] |
import java.util.Scanner;
public class RemoveCharacter {
public static String removeChar(String str, char ch){
//Your code goes here
String newStr = "";
for(int i = 0; i < str.length(); i++){
if(str.charAt(i) != ch){
newStr = newStr + str.charAt(i);
}
}
return newStr;
}
public static void main(String[] args){
try (Scanner s = new Scanner(System.in)) {
String str = s.nextLine();
char ch = s.next().charAt(0);
System.out.println(removeChar(str, ch));
}
}
}
| Web Proxy Viewer | New URL | Original Page |