Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #27258
| Newsgroups | comp.lang.java.programmer |
|---|---|
| Date | 2014-01-09 04:16 -0800 |
| Message-ID | <4bf24581-c504-4225-a584-38b3249e2edc@googlegroups.com> (permalink) |
| Subject | Newbee List question |
| From | Todor Atanasov <xumepoc@gmail.com> |
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??
Back to comp.lang.java.programmer | Previous | Next — 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