Luanrkiran kumar wrote:concept: Method chaining at page number 111 the output of the result should be AnimAl but the book says Animal.correct me if I was wrong.
The answer in the book is correct. toLowerCase() has changed the string to "animal" then replace method replaces "a" with "A".
So answer is Animal.
It is just chaining form of more elaborated example given above it (at the end of page 110 to beginning of 111 page ).
Have you tried executing the snippet?
Apologies for the quick misguided replay above. You are right. The answer is wrong(including the non chain example above).
"String java.lang.String.replace(char oldChar, char newChar)
Returns a string resulting from replacing all occurrences of oldChar in this string with newChar. "
Too bad i gave a wrong reply and i cannot edit or delete the post or is there any way to edit the post?