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


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

Re: Code Included: Freeze column

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> <nospam-D730B4.16293729052013@news.aioe.org> <b838090c-9d8e-48b2-bc22-582f7c61efb4@googlegroups.com> <nospam-6B3694.21402330052013@news.aioe.org> <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 <d45301ee-8f68-47b7-9a47-e8a1123ed33e@googlegroups.com> (permalink)
Subject Re: Code Included: Freeze column
From Lew <lewbloch@gmail.com>
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

Show key headers only | View raw


Haircuts Are Important wrote:
>Lew wrote:
>> Haircuts Are Important wrote:
>>> public class ModelWithScrollbar extends AbstractTableModel{
> > >    static public List<String> columnNames = new ArrayList();
> > >    static public List<List> data = new ArrayList();
> >
> > >    {//annonymous [sic] class
> >
> > There is no anonymous class here. Why the comment?
> 
> > >        for (int i = 0;i < 90; i++){
> > >           columnNames.add(" ");
> > >        }
> > >    }
> 
> 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 initializer. 
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 static 
construct.

That means that every instance of that class, should there ever be more 
than one, will add another 90 items to the 'columnNames' collection, resulting 
in a total size in excess of 90.

It is usually a bad idea to initialize a static structure in an instance context.

Study the following terms to be clear on these matters: "initializer" (both "static initializer" 
and "instance initializer"), "class", "anonymous class", "static member".

-- 
LEw

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


Thread

Code Included: Freeze column Haircuts Are Important <clusardi2k@aol.com> - 2013-05-29 12:55 -0700
  Re: Code Included: Freeze column "John B. Matthews" <nospam@nospam.invalid> - 2013-05-29 16:29 -0400
    Re: Code Included: Freeze column clusardi2k@aol.com - 2013-05-29 23:53 -0700
      Re: Code Included: Freeze column "John B. Matthews" <nospam@nospam.invalid> - 2013-05-30 21:40 -0400
        Re: Code Included: Freeze column Haircuts Are Important <clusardi2k@aol.com> - 2013-05-31 11:19 -0700
          Re: Code Included: Freeze column "John B. Matthews" <nospam@nospam.invalid> - 2013-05-31 23:59 -0400
            Re: Code Included: Freeze column Haircuts Are Important <clusardi2k@aol.com> - 2013-06-03 10:18 -0700
              Re: Code Included: Freeze column Haircuts Are Important <clusardi2k@aol.com> - 2013-06-03 12:48 -0700
              Re: Code Included: Freeze column "John B. Matthews" <nospam@nospam.invalid> - 2013-06-03 23:03 -0400
                Re: Code Included: Freeze column Haircuts Are Important <clusardi2k@aol.com> - 2013-06-04 05:05 -0700
                Re: Code Included: Freeze column "John B. Matthews" <nospam@nospam.invalid> - 2013-06-04 23:04 -0400
                Re: Code Included: Freeze column Haircuts Are Important <clusardi2k@aol.com> - 2013-06-05 11:53 -0700
                Re: Code Included: Freeze column "John B. Matthews" <nospam@nospam.invalid> - 2013-06-05 16:02 -0400
                Re: Code Included: Freeze column Lew <lewbloch@gmail.com> - 2013-06-05 13:09 -0700
                Re: Code Included: Freeze column clusardi2k@aol.com - 2013-06-05 16:27 -0700
                Re: Code Included: Freeze column Lew <lewbloch@gmail.com> - 2013-06-05 17:35 -0700
                Re: Code Included: Freeze column "John B. Matthews" <nospam@nospam.invalid> - 2013-06-06 21:42 -0400
                Re: Code Included: Freeze column Haircuts Are Important <clusardi2k@aol.com> - 2013-06-10 09:34 -0700
                Re: Code Included: Freeze column "John B. Matthews" <nospam@nospam.invalid> - 2013-06-10 13:49 -0400
                Re: Code Included: Freeze column Lew <lewbloch@gmail.com> - 2013-06-04 12:17 -0700
                Re: Code Included: Freeze column Haircuts Are Important <clusardi2k@aol.com> - 2013-06-04 12:54 -0700
                Re: Code Included: Freeze column Lew <lewbloch@gmail.com> - 2013-06-04 14:17 -0700
                Re: Code Included: Freeze column Joerg Meier <joergmmeier@arcor.de> - 2013-06-05 00:12 +0200
                Re: Code Included: Freeze column "John B. Matthews" <nospam@nospam.invalid> - 2013-06-04 21:39 -0400
                Re: Code Included: Freeze column Lew <lewbloch@gmail.com> - 2013-06-04 19:48 -0700
                Re: Code Included: Freeze column Joerg Meier <joergmmeier@arcor.de> - 2013-06-05 07:36 +0200
                Re: Code Included: Freeze column Lew <lewbloch@gmail.com> - 2013-06-04 22:46 -0700
        Re: Code Included: Freeze column Haircuts Are Important <clusardi2k@aol.com> - 2013-05-31 11:35 -0700
          Re: Code Included: Freeze column Lew <lewbloch@gmail.com> - 2013-05-31 11:43 -0700
            Re: Code Included: Freeze column Haircuts Are Important <clusardi2k@aol.com> - 2013-05-31 11:50 -0700
              Re: Code Included: Freeze column Lew <lewbloch@gmail.com> - 2013-05-31 12:37 -0700
                Re: Code Included: Freeze column Haircuts Are Important <clusardi2k@aol.com> - 2013-05-31 12:44 -0700
          Re: Code Included: Freeze column Haircuts Are Important <clusardi2k@aol.com> - 2013-05-31 12:30 -0700

csiph-web