Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #9007
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | markspace <-@.> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Cannot create a generic array of <type> |
| Date | Wed, 19 Oct 2011 12:21:29 -0700 |
| Organization | A noiseless patient Spider |
| Lines | 26 |
| Message-ID | <j7n7vs$266$1@dont-email.me> (permalink) |
| References | <j7lic6$lob$1@speranza.aioe.org> <11633107.472.1319005728890.JavaMail.geo-discussion-forums@prfp13> <j7m7nv$766$4@speranza.aioe.org> <j7mdic$67e$1@dont-email.me> <j7muo9$6oj$1@speranza.aioe.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Wed, 19 Oct 2011 19:21:32 +0000 (UTC) |
| Injection-Info | mx04.eternal-september.org; posting-host="XjIWM99mD7Ijfdu600oVPA"; logging-data="2246"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/9DsTFtkHKb3gk2YIiw1wOYJAmpNCppVg=" |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 |
| In-Reply-To | <j7muo9$6oj$1@speranza.aioe.org> |
| Cancel-Lock | sha1:FEFoYozqW19PsreeGJRoXRUyPbY= |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:9007 |
Show key headers only | View raw
On 10/19/2011 9:43 AM, Warren Tang wrote: > On 10/19/2011 7:50 PM, markspace wrote: >> On 10/19/2011 3:11 AM, Warren Tang wrote: >>> Thanks for the info. If I use the reified version of the generic - i.e. >>> the erased version of the generic - ArrayList instead of >>> ArrayList<Integer>, the compile error goes away and there is no run-time >>> error either. >>> >>> ArrayList<Integer>[] indexedValues = new ArrayList[5]; >>> >>> Although there is still a type safety warning. Because what you did is not type safe. It's also a terrible idea and poor practice. Bosses and co-workers will not like this sort of thing. > Sure. I just wanted to know why. What you have there is not the reified version of a generic. It's a raw type. It has no parameter type. It's a really bad idea to use raw types or to mix raw types and generics unless you must (there are a few specific instances where you can't avoid it). Here, you can almost certainly avoid raw types so do so.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
Cannot create a generic array of <type> Warren Tang <nospam@tangcs.com> - 2011-10-19 12:06 +0800
Re: Cannot create a generic array of <type> Warren Tang <nospam@tangcs.com> - 2011-10-19 13:22 +0800
Re: Cannot create a generic array of <type> Lew <lewbloch@gmail.com> - 2011-10-18 23:28 -0700
Re: Cannot create a generic array of <type> Warren Tang <nospam@tangcs.com> - 2011-10-19 18:11 +0800
Re: Cannot create a generic array of <type> markspace <-@.> - 2011-10-19 04:50 -0700
Re: Cannot create a generic array of <type> Warren Tang <nospam@tangcs.com> - 2011-10-20 00:43 +0800
Re: Cannot create a generic array of <type> markspace <-@.> - 2011-10-19 12:21 -0700
Re: Cannot create a generic array of <type> Warren Tang <nospam@tangcs.com> - 2011-10-21 11:05 +0800
Re: Cannot create a generic array of <type> Lew <lewbloch@gmail.com> - 2011-10-19 10:00 -0700
csiph-web