Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #5728

Re: The behavior of "equals" method of Arrays.asList() implementation

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail
From Lew <noone@lewscanon.com>
Newsgroups comp.lang.java.programmer
Subject Re: The behavior of "equals" method of Arrays.asList() implementation
Date Tue, 28 Jun 2011 07:29:06 -0400
Organization albasani.net
Lines 24
Message-ID <iucdtf$1mq$1@news.albasani.net> (permalink)
References <b30a98ec-acc8-4e7b-bb9d-0de48a554d07@g2g2000vbl.googlegroups.com> <iuccqd$i9p$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace news.albasani.net 0HbtENW09cwUY0MVwGxTpiHz1p676a+w5/F1s7215tYdIg/0MggHSlwFL+xlkK9XMBcmd+g6xw+/W+FHW+HcJeag/IStmMDkTBiKUQGJ0l6xIgrIo6+//OHCKVTIKInB
NNTP-Posting-Date Tue, 28 Jun 2011 11:28:48 +0000 (UTC)
Injection-Info news.albasani.net; logging-data="HwTQmvzZDpFO+S1LLmGS34IcfCuS4oI+bjqFsV1BZRcx2Iyo8bDNEK1KvcH8BioKQMUXOIXfwqdBsyo9/4ELKD1PpW6PT9hJDnStlvWwjrHPRcxgchYrKV8auRQ4XOjr"; mail-complaints-to="abuse@albasani.net"
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10
In-Reply-To <iuccqd$i9p$1@dont-email.me>
Cancel-Lock sha1:vSv7d7jucF9QM1rHWtew9OfBsFM=
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5728

Show key headers only | View raw


Eric Sosman wrote:
> Alex J wrote:
>> Basically I wonder if it is safe to use equals for collections (and
>> junit's assertEquals in particular which in fact results in the
>> *.equals invocation).
>>
>> One of collection instances I am working with is returned from
>> Arrays.asList(..) method invocation.
>> Sun JDK sources defines no equals method for
>> java.util.Arrays.ArrayList inner class so I guess it is not safe to
>> compare collections in that way.
>
> Look again. The nested class extends AbstractList, and
> inherits the equals() implementation from it.

Not only that, but
<http://download.oracle.com/javase/6/docs/api/java/util/List.html#equals(java.lang.Object)>
so of course it worked, and it had better be safe or the implementation is 
fubared.

-- 
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

The behavior of "equals" method of Arrays.asList() implementation Alex J <vstrength@gmail.com> - 2011-06-28 02:19 -0700
  Re: The behavior of "equals" method of Arrays.asList() implementation Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-06-28 07:08 -0400
    Re: The behavior of "equals" method of Arrays.asList() implementation Lew <noone@lewscanon.com> - 2011-06-28 07:29 -0400
  Re: The behavior of "equals" method of Arrays.asList() implementation Roedy Green <see_website@mindprod.com.invalid> - 2011-06-28 10:04 -0700

csiph-web