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


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

Re: String[] , Arrays.asList , Collections.unmodifiableList

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Stanimir Stamenkov <s7an10@netscape.net>
Newsgroups comp.lang.java.programmer
Subject Re: String[] , Arrays.asList , Collections.unmodifiableList
Date Sun, 11 May 2014 00:09:13 +0300
Organization A noiseless patient Spider
Lines 15
Message-ID <lkm4hk$uad$1@dont-email.me> (permalink)
References <bslom95b4j4s6eh4m5lfj6d3mq49uitlb3@4ax.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Sat, 10 May 2014 21:09:08 +0000 (UTC)
Injection-Info mx05.eternal-september.org; posting-host="6587700de30010f60e8e864aca9627a8"; logging-data="31053"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/3Ka40aRS/8Ozju4JkChn8"
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0 SeaMonkey/2.26
In-Reply-To <bslom95b4j4s6eh4m5lfj6d3mq49uitlb3@4ax.com>
X-Face "@)%Vlap6d%OVYDS}B4YUWE@yUy+^!w/+.q.,c5kjI#+uG?kYP&r/pTjNWgo:g[A,O=AL3/ j&4Le2cau$<e=FPq~GbeZ6DW1Grey[VHn8?ktzvoQtzlg;]&rh8g]CD+_BC7d[gW{Yx&_X*4Q$h&nJ l@t(|4R4:T='&]U#ui+z9OC$.~gJjU93kh:Ojc$Cz0n#I9!~!9ay?E<UlW&5,IFX1*KtA>MYEFst$y y"m]M7tq\S(>[a$x0x8%S
Cancel-Lock sha1:sDsn/MAlieSoOi6vkeGqxWE32tk=
Xref csiph.com comp.lang.java.programmer:28425

Show key headers only | View raw


Thu, 08 May 2014 21:30:08 -0700, /Roedy Green/:

> We have to use Collections.unmodifiableList which gives us a
> Collections.unmodifiableList wrapper around our List that throws
> UnsupportedOperationException when we attempt to write.
>
> The catch is the set methods are still there. We don't find out about
> the problem of modifying this list until run time.

I think this more or less a general rule: Don't assume a returned 
Collection (or Map) is mutable unless explicitly stated by the 
documentation / contract.

-- 
Stanimir

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


Thread

String[] , Arrays.asList , Collections.unmodifiableList Roedy Green <see_website@mindprod.com.invalid> - 2014-05-08 21:30 -0700
  Re: String[] , Arrays.asList , Collections.unmodifiableList leif.roar@invalid.com (Leif Roar Moldskred) - 2014-05-09 01:02 -0500
    Re: String[] , Arrays.asList , Collections.unmodifiableList Roedy Green <see_website@mindprod.com.invalid> - 2014-05-09 09:25 -0700
      Re: String[] , Arrays.asList , Collections.unmodifiableList leif.roar@invalid.com (Leif Roar Moldskred) - 2014-05-09 12:45 -0500
  Re: String[] , Arrays.asList , Collections.unmodifiableList Stanimir Stamenkov <s7an10@netscape.net> - 2014-05-11 00:09 +0300

csiph-web