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
Why is singleton class used?
What is the difference between instanceof and isinstance?
Explain when classnotfoundexception will be raised ?
Which containers use a flowlayout as their default layout in java programming?
How does a for loop work?
Where pragma is used?
What is gui programming?
What does this mean java?
What is the difference between iterator and list iterator?
Where are local variables stored?
Is there any tag in htm to upload and download files?
Which is better stringbuffer or stringbuilder?
Why synchronization is important?
Is finalize() similar to a destructor?
Define a package.