I have a String s = java; What is the output when I say
s.replaceAll('j', 'k'); Also what is the value of s after
replacing?
Answer Posted / prachi
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method replaceAll(String, String) in the type String is not applicable for the arguments (char, char)
will be thrown because in replaceAll(‘j’,’k’) : j & k are in single quote which defines as character not as string. For correct output first replace single quote with double quotes and second write s = s.replaceAll(“j”, “k”);
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is JVM and is it platform independent?
What is internal iteration in java se 8?
If I only change the return type, does the method become overloaded?
How to do encapsulation in java?
Can list contain null in java?
What are the special characters?
Is singleton class immutable?
What modifiers may be used with an inner class that is a member of an outer class in java programming?
What is blank final variable?
Why char array is favored over string for the storage of passwords?
What is meant by null and void?
What are local variables?
Does java have extension methods?
What is the method to expand and collapse nodes in a jtree?
What do you understand by private, protected and public?