Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.glorb.com!news-out.readnews.com!transit3.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail From: "Michael Dunn" Subject: Re: Help with code Message-ID: <4638643d@dnews.tpgi.com.au> X-Comment-To: comp.lang.java.gui Newsgroups: comp.lang.java.gui In-Reply-To: <46384a5e$0$19254$da0feed9@news.zen.co.uk> References: <46384a5e$0$19254$da0feed9@news.zen.co.uk> Content-Type: text/plain; charset=IBM437 Content-Transfer-Encoding: 8bit X-Gateway: time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92] Lines: 30 Date: Wed, 27 Apr 2011 15:34:02 GMT NNTP-Posting-Host: 96.60.20.240 X-Complaints-To: news@tds.net X-Trace: newsreading01.news.tds.net 1303918442 96.60.20.240 (Wed, 27 Apr 2011 10:34:02 CDT) NNTP-Posting-Date: Wed, 27 Apr 2011 10:34:02 CDT Organization: TDS.net Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.gui:1561 To: comp.lang.java.gui "Ian Wilson" wrote in message news:46384a5e$0$19254$da0feed9@news.zen.co.uk... > Michael Dunn wrote: > > > > Expressions involving x and y tend to make me think of cartesian coordinates, I had to do a double > take to check you were using FlowLayout for the buttons and not GridLayout. > >> for(int x= 0, y = btns.length; x < y; x++) > > Why not > for(int x = 0; x < btns.length; x++) > > I've always imagined that the compiler or JVM would do the obvious optimisation. Is there > something I'm missing? > absolutely no idea how the JVM optimises, I've just assumed that btns.length would be called/evaluated on each loop and that it would be better to do this only once. If it makes no difference, then for(int x = 0; x < btns.length; x++) is a simpler way to do it. --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24