Article View: be.comp.programming
Article #3681Re: marking a postion in a Java Collection
From: Tim Van Wassenhove
Date: Fri, 07 Nov 2003 20:55
Date: Fri, 07 Nov 2003 20:55
31 lines
1853 bytes
1853 bytes
On 2003-11-07, Stino <hehe@hotmail.com> wrote:
> hi all,
>
> I'm trying to do the following in Java.
> I have a class that contains an ArrayList.
> At certain points in the program I want to mark a position in the ArrayList.
>
> e.g. If I had "A" and "B" then 'mark' and then add "C" and "D"
> Then, when I say, 'showFrom()" I should only get to see "C" and "D".
> I tried to use an Iterator to do this, but with no succes.
> I get the following
>
> Exception in thread "main" java.util.ConcurrentModificationException
> at
> java.util.AbstractList$Itr.checkForComodification(AbstractList.java:444)
> at java.util.AbstractList$Itr.next(AbstractList.java:417)
> at IteratorTest.moveIterator(IteratorTest.java:27)
> at IteratorTest.main(IteratorTest.java:41)
>
> public void showFrom() {
> Iterator ii = i;
> while (ii.hasNext()) System.out.print(ii.next());
> }
>
Een gokje, ArrayList is niet thread-safe?
--
Visit my website at http://home.scarlet.be/~vwadsl
My jabber handle is aardbei@jabber.org
Technical Details
Message-ID:
<boh0rn$1dvdsj$3@ID-188825.news.uni-berlin.de>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!kn-upc-1.kuleuven.NET!not-for-mailReferences:
<ZvTqb.9547$uj1.222276@phobos.telenet-ops.be>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fcea4,3bfdd26d3dc7ca4f X-Google-Attributes: gidfcea4,public X-Google-ArrivalTime: 2003-11-07 12:55:21 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!kn-upc-1.kuleuven.NET!not-for-mail From: Tim Van Wassenhove <euki@pi.be> Newsgroups: be.comp.programming Subject: Re: marking a postion in a Java Collection Date: 7 Nov 2003 20:55:19 GMT Lines: 31 Message-ID: <boh0rn$1dvdsj$3@ID-188825.news.uni-berlin.de> References: <ZvTqb.9547$uj1.222276@phobos.telenet-ops.be> NNTP-Posting-Host: kn-upc-1.kuleuven.net (134.58.253.193) X-Trace: news.uni-berlin.de 1068238519 48215955 134.58.253.193 (16 [188825]) User-Agent: slrn/0.9.8.0 (Linux)