Remove character in a given string
class RemoveChar{
public static void main(String args[]){
String val=removeChar("Madhusudhan Reddy",'u');
System.out.println(val);
}
public static String removeChar(String s, char c) {
String r = "";
for (int i = 0; i < s.length(); i ++) {
if (s.charAt(i) != c) r += s.charAt(i);
}
return r;
}
}
public static void main(String args[]){
String val=removeChar("Madhusudhan Reddy",'u');
System.out.println(val);
}
public static String removeChar(String s, char c) {
String r = "";
for (int i = 0; i < s.length(); i ++) {
if (s.charAt(i) != c) r += s.charAt(i);
}
return r;
}
}
Comments
Post a Comment
Please post comments here:-)