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 / puneet

No, the strings are immutable; the value of s will be the
same but new object kava will get crated which wil have no
refrence. s will refer to the same object which is not
changed.
s=s.replace("",""); should have worked...otherways

Is This Answer Correct ?    4 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain about data types?

586


What is foreach loop in java?

542


Can we declare a class as static?

600


What are the advantages of packages in java?

576


What are the types of collections in java?

548






Can an interface have a constructor?

520


What is mean by exception?

556


What is arraylist e in java?

528


Write a code to show a static variable?

620


What methodology can be employed to locate substrings inside a string?

541


What is the difference between comparison done by equals method and == operator?

578


Write a method that will remove given character from the string?

581


Write down program for following scenario. Use java coding standard. You have array list with some words in it..we will call it as dictionary….and you have a arbitrary string containing some chars in it. You have to go through each word of dictionary and find out if that word can be constructed with the help of chars from arbitrary string given. If you find the word print it else print none.

2291


Is string is a keyword in java?

553


What is difference between calling start() and run() method of thread?

565