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

Define locale.

588


Can a class have a static inner class?

606


State some situations where exceptions may arise in java?

627


What is the size of int?

598


why we use merge option in hybernate pls give a ex snippet

1459






How do you sort an array in java?

541


Explain method overloading?

573


What is the difference between the ">>" and " >>>" operators in java?

509


What are the basic interfaces of java collections framework?

605


What is stringwriter?

537


What does jre stand for?

607


what is a working thread? : Java thread

553


Which graphs are functions?

494


What is math exp in java?

544


What is the use of hashmap in java?

552