Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #37255
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: A new small quiz question |
| Date | 2017-08-16 08:30 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <on1dm4$6bp$1@dont-email.me> (permalink) |
| References | <quiz-20170816122427@ram.dialup.fu-berlin.de> |
On 8/16/2017 7:25 AM, Stefan Ram wrote:
> Can you predict (without trying it out) what the output
> of the following program is?
Yes.
> public final class Main
> {
> private static int f( final int i )
> { java.lang.System.out.println( i ); return i; }
>
> public static void main( final java.lang.String[] args )
> { int[] x = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
>
> x[ f( 0 )]= x[ f( 1 )]= x[ f( 2 )];
>
> java.lang.System.out.println( x[ 0 ]); }}
Unlike many of your other quizzes and curiosities, this
one appears to have some pedagogic value. However, I'm sure
the lesson could be conveyed with less obfuscation. Also,
were I teaching Java I would follow the advice of JLS 15.7
and discourage students from employing this linguistic oddity.
--
esosman@comcast-dot-net.invalid
Twelve hundred fifty-three days to go.
Back to comp.lang.java.programmer | Previous | Next | Find similar | Unroll thread
Re: A new small quiz question Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-08-16 08:30 -0400
csiph-web