Path: csiph.com!feeder.erje.net!2.eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: array of HashSet<> Date: Sun, 28 Feb 2016 13:27:46 -0500 Organization: A noiseless patient Spider Lines: 42 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sun, 28 Feb 2016 18:24:44 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="2d081e2f7155c28005d4472f67c2f43d"; logging-data="17058"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Bnk6LyAqL0+dKCErBY9nd" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 In-Reply-To: Cancel-Lock: sha1:1zCuv8qNwratXaQB3S8utoGMvWs= Xref: csiph.com comp.lang.java.programmer:33898 On 2/28/2016 12:47 PM, Arne Vajhøj wrote: > On 2/28/2016 8:56 AM, Eric Sosman wrote: >> On 2/28/2016 8:38 AM, Arne Vajhøj wrote: >>> On 2/28/2016 2:44 AM, Roedy Green wrote: >>>> I am not trying to arrange the HashSet fields in order in an array. I >>>> am just trying to do something like this: >>>> >>>> private final HashSet[] hashSets; >>> >>>> hashSets = new HashSet[ filesToProcess.length ]; >>> >>>> I get this error message: >>>> >>>> Warning:(104, 20) java: unchecked conversion >>>> required: java.util.HashSet[] >>>> found: java.util.HashSet[] >>> >>> hashSets = new HashSet[ filesToProcess.length ] >>> >>> should fix that. >> >> ... for suitable values of "fix." >> >> JLS 15.10.1, Array Creation Expressions: "It is a compile-time >> error if the ClassOrInterfaceType does not denote a reifiable type." > > Ooops. > > You are right. > > That does not work. Alas, no. A continuing and damnable annoyance. > One of the ugly cast and suppress solutions are necessary. Lew's dodge using a variadic function is nice. Nicer than casts, anyhow, because it retains type safety. -- esosman@comcast-dot-net.invalid "Don't be afraid of work. Make work afraid of you." -- TLM