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
How is hashcode calculated in java?
How can I debug the Java security exceptions and AccessControlExceptions?
When should a function throw an exception?
What is unmodifiable collection in java?
What is the basic concept of java?
What is the difference between access specifiers and access modifiers in java?
Why is sizeof not a function?
Why do we use bufferedreader?
Is java hard to learn?
Explain java code for recursive solution's base case?
What is the purpose of format function?
What is string buffer?
What is collection api?
Can a class be private or protected in java?
What is io stream in java?