+ 1
Java question
write a method called remove() that takes two arguments : String and character, and returns new String that removes all accurences of the character from the input String
5 odpowiedzi
+ 1
The answer
package test3;
public class method2009 {
public static String remove(String a , char b) {
for(int i = 0 ; i < a.length() ; i++){
if(a.charAt(i) !=b){
String res = "";
res = res + a.charAt(i);
System.out.print(res);
}
}
return null;
}
public static void main (String [] args){
remove("programming" , 'm');
}
}
+ 1
Just use a loop to go through each character in the string and test if its the character. If it isn't, add it to some temp string.
When the loop is finished, return the temp string.
+ 1
No, I'm not going to do your homework. I already tolled you how to do it anyway.
0
can you write complete code
i think you should use charAt() method
0
it is not my homework but thank you anyway.