Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #37255 > unrolled thread

Re: A new small quiz question

Started byEric Sosman <esosman@comcast-dot-net.invalid>
First post2017-08-16 08:30 -0400
Last post2017-08-16 08:30 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.java.programmer

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: A new small quiz question Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-08-16 08:30 -0400

#37255 — Re: A new small quiz question

FromEric Sosman <esosman@comcast-dot-net.invalid>
Date2017-08-16 08:30 -0400
SubjectRe: A new small quiz question
Message-ID<on1dm4$6bp$1@dont-email.me>
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.

[toc] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web