• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

wrong result in ocajp 8 jeanne and scott book(i guess).

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 7
Eclipse IDE Oracle Notepad
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?
 
steve jhonson
Greenhorn
Posts: 7
Eclipse IDE Oracle Notepad
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Marshal
Posts: 65755
250
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

steve jhonson wrote:. . . is there any way to edit the post?

We mods can edit posts if required however. I don't think editing would be helpful here, but it might be worth removing your quote of your own post; I can permit you to remove the old quote.

@all

Please read this.

Luanrkiran kumar, welcome to the Ranch
 
Luanrkiran kumar
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it's ok, thank you for replying back I went crazy when I saw your first post lol.
 
Come have lunch with me Arthur. Adventure will follow. This tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!