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


Groups > comp.lang.java.programmer > #32198

Re: Array initialization

From Daniel Pitts <newsgroup.nospam@virtualinfinity.net>
Newsgroups comp.lang.java.programmer
Subject Re: Array initialization
References <Array-20150729080212@ram.dialup.fu-berlin.de>
Message-ID <G2bux.9980$VD4.2272@fx07.iad> (permalink)
Date 2015-07-29 13:52 -0700

Show all headers | View raw


On 7/28/15 11:06 PM, Stefan Ram wrote:
>    Recently, being away from the keyboard, I wondered whether
>    the following was legal in Java:
>
> public final class Main
> { public static void main( final java.lang.String[] args )
>    { int a[] ={ 0, a[ 0 ] + 1, a[ 1 ]+ 1 };
>     java.lang.System.out.println( a[ 0 ]);
>     java.lang.System.out.println( a[ 1 ]);
>     java.lang.System.out.println( a[ 2 ]); }}
>
>    Turned out, I got an error message:
>
> Main.java:3: error: variable a might not have been initialized
>    { int a[] ={ 0, a[ 0 ]+ 1, a[ 1 ]+ 1 };
>                    ^
> 1 error
>


Yep, that makes total sense. I wouldn't expect anything different.

Back to comp.lang.java.programmer | Previous | Next | Find similar | Unroll thread


Thread

Re: Array initialization Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2015-07-29 13:52 -0700

csiph-web