Jan Groth
,
Ranch Hand
Nov 08, 2005 02:50:00
okay, not a real question, but cool stuff i found in a java book. the following code compiles without errors: but why? oviously it's lame to try it out in your IDE . furthermore it's lame to post the solution in the thread , instead you can post the time you needed... almost everyone i showed this code needed a couple of minutes, even our senior java architects. guess our brain is kind of biased... :-) enjoy, jan
Ritesh Agrawal
,
Ranch Hand
Nov 08, 2005 03:18:00
Hi, Nice and smart stuff..took me about 90 secs to find out the trick.. True .. our minds are biased.. Cheers!!
Srinivasa Raghavan
,
Ranch Hand
Nov 08, 2005 03:47:00
Wow very nice .. Took 3 minutes ( approx ) to figure out .. [ November 08, 2005: Message edited by: Srinivasa Raghavan ]
Jim Yingst
,
Wanderer
staff
Nov 08, 2005 03:53:00
[Jan]: cool stuff i found in a java book. Credit where it's due: I believe the book referred to here is Java Puzzlers by Joshua Bloch and Neal Gafter. Highly recommended. Sadly the authors did not actually use the Big Moose Saloon URL in their example, instead choosing to reference their current employer. But we can't have everything I suppose.
Jan Groth
,
Ranch Hand
Nov 08, 2005 04:01:00
actually i found it in a german java book "java ist auch eine insel" ("java is an island, too")... :-)
Stuart Ash
,
Ranch Hand
Nov 08, 2005 05:18:00
Originally posted by Jan Groth: actually i found it in a german java book "java ist auch eine insel" ("java is an island, too")... :-)
Yeah, Germans are good at combining several tens of words while writing German and then splitting them apart in their mind while reading. English-speakers don't do that for a full-time job.
Steve Morrow
,
Ranch Hand
Nov 08, 2005 06:33:00
ooviously it's lame to try it out in your IDE. furthermore it's lame to post the solution in the thread, instead you can post the time you needed...
About 15 seconds. It may be a bit easier for those who spend a lot of time dinking around in the SCJP forum, where the discussion revolves around esoteric constructs like this. Nice puzzle!
Stan James
,
(instanceof Sidekick)
Nov 08, 2005 10:35:00
Nice. I passed it around and somebody else got it in a minute or so.
ritu singhal
,
Greenhorn
Nov 08, 2005 14:43:00
COuld u please explain why it worked ??
Bear Bibeault
,
Sheriff
staff
Nov 08, 2005 15:13:00
COuld u please explain why it worked ??
Don't scroll down if you don't want to know the answer quite yet.... It's a label followed by a comment. [ November 08, 2005: Message edited by: Bear Bibeault ] [ November 08, 2005: Message edited by: Bear Bibeault ]
Tony Morris
,
Ranch Hand
Nov 08, 2005 21:12:00
The question existed well before Java Puzzlers did. http://jqa.tmorris.net/GetQAndA.action?qids=78&showAnswers=true
Ernest Friedman-Hill
,
author and iconoclast
staff
Nov 08, 2005 21:28:00
OK, here's a question for the old-timers: I could swear that at one time, only loops could be labeled in Java. Was this ever true, proposed to be true, reputed to be true, true of a certain implementation, or otherwise non-false in any situation?
Archies Gomes
,
Ranch Hand
Nov 09, 2005 06:33:00
Hi A nice one infact....Didnt strike at the first glance but when u said its lame to send the solution ...got that in nearly 15 secs... Good one,
Mr. C Lamont Gilbert
,
Ranch Hand
Nov 09, 2005 06:44:00
Stefan Evans
,
Bartender
staff
Nov 09, 2005 17:14:00
>I could swear that at one time, only loops could be labeled in Java. Any statement can be labelled. You can use break with any label You can only use continue with a label on a loop statement. That may be where the confusion comes from. There is an example here: http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.15
Akshay Kiran
,
Ranch Hand
Nov 11, 2005 09:41:00
When you have exhausted all possibilities, remember this: you haven't - Edison. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com