Path: csiph.com!aioe.org!.POSTED!not-for-mail From: Robert Spanjaard Newsgroups: comp.lang.java.programmer Subject: Re: Can't use block of statements as 'incrementer' in for loop? Date: Thu, 15 Feb 2018 12:05:03 +0100 Organization: Aioe.org NNTP Server Lines: 24 Message-ID: References: NNTP-Posting-Host: bL5gwq6hANUN7rOnAkKsyA.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.8.3 Xref: csiph.com comp.lang.java.programmer:38024 On 14-02-18 19:57, Eric Douglas wrote: > On Wednesday, February 14, 2018 at 11:01:48 AM UTC-5, Robert Spanjaard wrote: >> https://docs.oracle.com/javase/tutorial/java/nutsandbolts/expressions.html > > That documentation says "... types of expressions can be made into a statement by terminating the expression with a semicolon" > > as you see in the docs Arne refers to the 'ForUpdate' section may include multiple expressions separated by comma. > https://docs.oracle.com/javase/specs/jls/se8/html/jls-14.html#jls-14.14.1 > > So try like this: > public static void main(final String[] args) { > ArrayList a1; > for (int i = 1, j; i < 11; j = 2, i++, System.out.println("Hello World!"), a1 = new ArrayList<>(), a1.add(j)) { > System.out.println("Count is: " + i); > } > } > Yes, but that same doc lists System.out.println as an example of a statement. But OK, I think Arne and you got me on the right track. Thanks. -- Robert Spanjaard