Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #27261
| Newsgroups | comp.lang.java.programmer |
|---|---|
| Date | 2014-01-09 06:52 -0800 |
| References | <4bf24581-c504-4225-a584-38b3249e2edc@googlegroups.com> |
| Message-ID | <5315cf7a-be8d-4057-a11e-76d5f08dfe9f@googlegroups.com> (permalink) |
| Subject | Re: Newbee List question |
| From | Todor Atanasov <xumepoc@gmail.com> |
09 януари 2014, четвъртък, 14:16:42 UTC+2, Todor Atanasov написа:
> Hi,
>
> I am very new to the JAVA, but I have some experience in programming, like C++/MFC and php.
>
>
>
> I have a question regarding List, and more precisely a specific case which I fail to get the logic.
>
>
>
> This is the example code:
>
>
>
> List groups = new ArrayList();
>
> List group = null;
>
> for(int i = 0; i < 20; i++{
>
> TestClass test = new TestClass();
>
> if(group == null || flag)){
>
> group = new ArrayList();
>
> groups.add(group);
>
> }
>
>
>
>
>
> ...... //the flag is set on some condition
>
> group.add(test);
>
>
>
> }
>
>
>
> I get the first nationalization of the group list with new ArrayList, but isn't every single group list after that, when the flag is set, also initialized, resulting in a empty group, which are then added to the groups??
Thank you both for the reply, I will have to look more deeply into the logic here :D
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Newbee List question Todor Atanasov <xumepoc@gmail.com> - 2014-01-09 04:16 -0800
Re: Newbee List question Joerg Meier <joergmmeier@arcor.de> - 2014-01-09 13:38 +0100
Re: Newbee List question leif.roar@invalid.com (Leif Roar Moldskred) - 2014-01-09 07:50 -0600
Re: Newbee List question Tim Slattery <tim@risingdove.com> - 2014-01-09 14:12 -0500
Re: Newbee List question leif.roar@invalid.com (Leif Roar Moldskred) - 2014-01-09 14:41 -0600
Re: Newbee List question Todor Atanasov <xumepoc@gmail.com> - 2014-01-09 06:52 -0800
Re: Newbee List question Roedy Green <see_website@mindprod.com.invalid> - 2014-02-03 19:36 -0800
Re: Newbee List question Roedy Green <see_website@mindprod.com.invalid> - 2014-02-03 19:39 -0800
csiph-web