Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: supercalifragilisticexpialadiamaticonormalizeringelimatisticantations Newsgroups: comp.lang.java.programmer Subject: Re: looping through a list, starting at 1 Date: Thu, 11 Aug 2011 09:52:55 -0400 Organization: supercalifragilisticexpialadiamaticonormalizeringelimatisticantations Lines: 25 Message-ID: References: <4e3745a2$0$305$14726298@news.sunsite.dk> <62239393-929c-4764-8c8e-9620a03a7b81@c29g2000yqd.googlegroups.com> <80346568-647c-4e27-8192-33e1765a09ce@glegroupsg2000goo.googlegroups.com> NNTP-Posting-Host: ctQg44ykOdWcgFJPjQET+w.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: WinVN 0.99.12z (x86 32bit) X-Notice: Filtered by postfilter v. 0.8.2 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7018 On 11/08/2011 6:02 AM, Arved Sandstrom wrote: > I specifically answered your question "Are marker-interfaces (which > RandomAccess is, iirc) already an antipattern". IMO they are not, for > reasons stated. But this non-anti-pattern explanation emphasizes their > use as compile-time new types. Their not inconsiderable utility here > stems from the fact that the marker interface guarantees a behaviour in > a documented contract - it's up to the implementor to meet those guarantees. It's up to the implementor to meet guarantees with any interface, even one that declares methods. The compiler can enforce the presence of methods with particular signatures, but that's as far as it goes. It's as easy to write a delegate EvilList extends LinkedList implements RandomAccess and to write something like: public class EvilIterator implements Iterator { public boolean hasNext () { return true; } public String next () { throw new NoSuchElementException(); } public void remove () { throw new IllegalArgumentException(); } }