Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Guess what this prints...

 
Hemal Mehta
Ranch Hand
Posts: 101
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

and why ofcourse?
Also what steps will the toString method be executed 3 times by the compiler?
[ Jess added UBB [code] tags to preserve whitespace, check 'em out! ]
[ January 30, 2003: Message edited by: Jessica Sant ]
 
John Paverd
Ranch Hand
Posts: 115
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or to put it another way, is this class shouting into Echo canyon, or just trying to look busy while doing nothing
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it prints just what you expect...
Guess what this is hello
Check out the API for String.toString()
"This object (which is already a string!) is itself returned."
Do you expect something else to happen??
 
Dominic Choo
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The result is:
==============================================
Guess what this is hello
==============================================
Not printing the hello for three times.
 
Jasper Vader
Ranch Hand
Posts: 284
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

this would probably give you a cool echo-chamber result, used to great effect by Led Zepelin in the seventies.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic