X-Received: by 10.224.200.202 with SMTP id ex10mr7283451qab.8.1370029061078; Fri, 31 May 2013 12:37:41 -0700 (PDT) X-Received: by 10.50.127.231 with SMTP id nj7mr675129igb.17.1370029061043; Fri, 31 May 2013 12:37:41 -0700 (PDT) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!ch1no187472qab.0!news-out.google.com!y6ni158qax.0!nntp.google.com!ch1no187465qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.java.programmer Date: Fri, 31 May 2013 12:37:40 -0700 (PDT) In-Reply-To: <1beef50f-c077-4af0-b2c6-a122040eeda4@g7g2000vbv.googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.28.149.29; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T NNTP-Posting-Host: 69.28.149.29 References: <566ff119-faa8-4116-9761-65002a3c1cb3@w8g2000yqf.googlegroups.com> <18504f7e-143d-4366-a1fd-c16744135b08@j7g2000vbj.googlegroups.com> <581639b5-3d24-436f-9f72-f44b4a260aae@googlegroups.com> <1beef50f-c077-4af0-b2c6-a122040eeda4@g7g2000vbv.googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Code Included: Freeze column From: Lew Injection-Date: Fri, 31 May 2013 19:37:41 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: csiph.com comp.lang.java.programmer:24213 Haircuts Are Important wrote: >Lew wrote: >> Haircuts Are Important wrote: >>> public class ModelWithScrollbar extends AbstractTableModel{ > > > =A0 =A0static public List columnNames =3D new ArrayList(); > > > =A0 =A0static public List data =3D new ArrayList(); > > > > > =A0 =A0{//annonymous [sic] class > > > > There is no anonymous class here. Why the comment? >=20 > > > =A0 =A0 =A0 =A0for (int i =3D 0;i < 90; i++){ > > > =A0 =A0 =A0 =A0 =A0 columnNames.add(" "); > > > =A0 =A0 =A0 =A0} > > > =A0 =A0} >=20 > If it's not an annonymous [sic] class what is it called. If by "it" you mean the block with the 'for' loop in it, that is an initial= izer.=20 It is not any kind of class, let alone an anonymous one. It is also a bug. You are using an instance initializer to initialize a sta= tic=20 construct. That means that every instance of that class, should there ever be more=20 than one, will add another 90 items to the 'columnNames' collection, result= ing=20 in a total size in excess of 90. It is usually a bad idea to initialize a static structure in an instance co= ntext. Study the following terms to be clear on these matters: "initializer" (both= "static initializer"=20 and "instance initializer"), "class", "anonymous class", "static member". --=20 LEw