Java Puzzlers - 'Hello Whirled' challenge
posted 10 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Just for fun, here's a little challenge from the book. (if you have the book, no cheating)
Take the following code, and tell me what does it print?
Take the following code, and tell me what does it print?
Tim Driven Development | Test until the fear goes away
posted 10 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
It initially looked it would print "Hello world". But then I copied the code and when I tried to compile it, I realised the error! Interesting find.
Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook | Java 11 Cookbook
posted 10 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I too guessed output to be Hello world, and then to check my answer, tried to copy the code and run. Unfortunately, I copied only the code part (without comment), so it worked perfectly for me :P . I had to look up the answer in the book to find out what am I missing.
posted 10 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
It was a real devil this one I thought.
For the benefit of everyone else, the twist in this code was the fact that the compiler was attempting to interpret some UniCode value in the comment block when it encountered a \u pattern. So in the comment line:
from F:\TestRoot\apps\a1\units\include\PolicyHome.idl
The Java Compiler is attempting to resolve "\units" as Unicode, which it is not, so fails.
For the benefit of everyone else, the twist in this code was the fact that the compiler was attempting to interpret some UniCode value in the comment block when it encountered a \u pattern. So in the comment line:
from F:\TestRoot\apps\a1\units\include\PolicyHome.idl
The Java Compiler is attempting to resolve "\units" as Unicode, which it is not, so fails.
Tim Driven Development | Test until the fear goes away
posted 10 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Agree; if you miss out that documentation comment you do indeed get Hello world.
| That new kid is a freak. Show him this tiny ad: The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |









