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

What are the steps in the jdbc connection?

578


What do you know about the garbage collector in java?

575


Can extern variables be initialized?

516


What is Java Shutdown Hook?

617


what are different ways in which a thread can enter the waiting state? : Java thread

496






Difference between arraylist and vector.

594


Does java initialize arrays to zero?

512


Explain about the interpreter in java?

627


What is a substitution variable?

569


Which java ide is used the most?

511


Is null == null in java?

654


Why do you canvas?

616


what are Hostile Applets?

1610


What are the two types of java programming?

541


why would you use a synchronized block vs. Synchronized method? : Java thread

537