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


Please Help Members By Posting Answers For Below Questions

How is hashcode calculated in java?

713


How can I debug the Java security exceptions and AccessControlExceptions?

904


When should a function throw an exception?

813


What is unmodifiable collection in java?

709


What is the basic concept of java?

770


What is the difference between access specifiers and access modifiers in java?

836


Why is sizeof not a function?

761


Why do we use bufferedreader?

736


Is java hard to learn?

690


Explain java code for recursive solution's base case?

778


What is the purpose of format function?

850


What is string buffer?

717


What is collection api?

808


Can a class be private or protected in java?

798


What is io stream in java?

740