Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #36291
| Path | csiph.com!feeder.erje.net!2.eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Robert Klemme <shortcutter@googlemail.com> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Removing an element while iterating over a List with enhanced for? |
| Date | Thu, 16 Feb 2017 18:30:02 +0100 |
| Lines | 31 |
| Message-ID | <egm5srFomftU1@mid.individual.net> (permalink) |
| References | <o82m7a$tls$1@dont-email.me> <o83759$lhe$1@gioia.aioe.org> <o84mo2$lrp$1@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | quoted-printable |
| X-Trace | individual.net RSuVsJE4/1dULxDGqbvaowRu8LtcOjzBPam77X/89ZgwtRi38= |
| Cancel-Lock | sha1:OtW9vXzkJ28IQywP09Thpt/UMjE= |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 |
| In-Reply-To | <o84mo2$lrp$1@dont-email.me> |
| Xref | csiph.com comp.lang.java.programmer:36291 |
Show key headers only | View raw
On 16.02.2017 18:17, Knute Johnson wrote:
> On 2/15/2017 21:43, Arne Vajhøj wrote:
>> On 2/15/2017 5:56 PM, Knute Johnson wrote:
>>> An enhanced for loop on a List is no different than using an Iterator
>>> right? So is there any problem removing the current element from the
>>> list while using the enhanced for loop? I couldn't find anything that
>>> said it was OK or not OK in the JLS.
>>
>>> List<Integer> list = Stream.of(1,5,7,9,13).collect(toList());
Btw. I know it is just the code to get a list filled but still you can
have that much simpler:
list = Arrays.asList(1, 5, 7, 9, 13);
We tend to forget the "good ole code" over all the fancy new things. :-)
Cheers
robert
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Removing an element while iterating over a List with enhanced for? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2017-02-15 16:56 -0600
Re: Removing an element while iterating over a List with enhanced for? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-02-15 18:24 -0500
Re: Removing an element while iterating over a List with enhanced for? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2017-02-15 17:51 -0600
Re: Removing an element while iterating over a List with enhanced for? Arne Vajhøj <arne@vajhoej.dk> - 2017-02-15 22:43 -0500
Re: Removing an element while iterating over a List with enhanced for? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2017-02-16 11:17 -0600
Re: Removing an element while iterating over a List with enhanced for? Robert Klemme <shortcutter@googlemail.com> - 2017-02-16 18:30 +0100
Re: Removing an element while iterating over a List with enhanced for? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2017-02-16 11:35 -0600
Re: Removing an element while iterating over a List with enhanced for? Arne Vajhøj <arne@vajhoej.dk> - 2017-02-16 14:02 -0500
Re: Removing an element while iterating over a List with enhanced for? v_borchert@despammed.com (Volker Borchert) - 2017-02-16 20:09 +0000
Re: Removing an element while iterating over a List with enhanced for? Robert Klemme <shortcutter@googlemail.com> - 2017-02-16 23:21 +0100
csiph-web