Write a method that will remove given character from the string?



Write a method that will remove given character from the string?..

Answer / Tanuj Rastogi

public String removeChar(String str, char c) {n StringBuilder sb = new StringBuilder();n for (int i = 0; i < str.length(); i++) {n if (str.charAt(i) != c)n sb.append(str.charAt(i));n }n return sb.toString();n}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is OOP?

2 Answers   BMC, Microsoft,


I want to run a simple hello world java (HelloWorld.java) program using a batch file. How can i run it and how to construct a batch file.

1 Answers   Infosys,


Can a class be final?

1 Answers  


How do you compare objects in java?

1 Answers  


What is local variable and instance variable?

1 Answers  


How to convert a string to long?

2 Answers  


how to print a numbers from 1 to 100 with out using control structures?

4 Answers   IBM,


What is anagram number?

1 Answers  


Difference between method overloading and overriding.

1 Answers  


What is number data type?

1 Answers  


Which collection is sorted in java?

1 Answers  


how come we know the object is no more used in the class?

3 Answers   Accenture,


Categories