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


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

Re: Code Included: Freeze column

Newsgroups comp.lang.java.programmer
Date 2013-05-31 12:37 -0700
References (2 earlier) <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>
Message-ID <d45301ee-8f68-47b7-9a47-e8a1123ed33e@googlegroups.com> (permalink)
Subject Re: Code Included: Freeze column
From Lew <lewbloch@gmail.com>

Show all headers | 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