Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #6405
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail |
|---|---|
| From | Sebastian <sebastian@undisclosed.invalid> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Problem with generics and dynamic array copy |
| Date | Fri, 22 Jul 2011 19:26:21 +0200 |
| Organization | albasani.net |
| Lines | 23 |
| Message-ID | <j0cbru$289$1@news.albasani.net> (permalink) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-15; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.albasani.net b+h1IX8JrBqckGEbPJ45B8Sf3N16+f+cU0Vc+Ko2+egeRwppflTeqxTXo2N/RQ1T99XVTaUwC3GT/v0V5/3iwA== |
| NNTP-Posting-Date | Fri, 22 Jul 2011 17:26:22 +0000 (UTC) |
| Injection-Info | news.albasani.net; logging-data="AnUC/Pj5D6fUaHepO+dLg+hr8iEb0reKAqOibCo+sjpBysFkUOFvvLZ12wP+tR7wgWzWH1f3idMhHVJhJhAONYckHe1heHJeJxtGTDlJHeg/gaK5utza4xPW+8awCzXU"; mail-complaints-to="abuse@albasani.net" |
| User-Agent | Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 |
| Cancel-Lock | sha1:lPIpfosM4I9l5qg5xrQCOwFZGGw= |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6405 |
Show key headers only | View raw
Hello there,
how can I make the compile error go away? The marked line is wrong:
Type mismatch: cannot convert from Class<capture#2-of ?> to Class<T>
/**
* Copies the specified array to a new array with the same component
* type and length as the given array.
* @param <T> the type of the array elements
* @param src the array to be copied
* @return the copy
*/
public static final <T> T[] arraycopy( T[] src )
{
Class<T> componentType = src.getClass().getComponentType(); // !!!!
@SuppressWarnings("unchecked")
T[] dest = (T[]) Array.newInstance( componentType, src.length );
System.arraycopy( src, 0, dest, 0, src.length );
return dest;
}
I'd be grateful for a hint.
-- Sebastian
Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar
Problem with generics and dynamic array copy Sebastian <sebastian@undisclosed.invalid> - 2011-07-22 19:26 +0200
Re: Problem with generics and dynamic array copy Sebastian <sebastian@undisclosed.invalid> - 2011-07-22 19:30 +0200
Re: Problem with generics and dynamic array copy markspace <-@.> - 2011-07-22 11:23 -0700
Re: Problem with generics and dynamic array copy Sebastian <sebastian@undisclosed.invalid> - 2011-07-22 20:36 +0200
Re: Problem with generics and dynamic array copy Robert Klemme <shortcutter@googlemail.com> - 2011-07-22 21:27 +0200
Re: Problem with generics and dynamic array copy lewbloch <lewbloch@gmail.com> - 2011-07-22 13:33 -0700
Re: Problem with generics and dynamic array copy Sebastian <sebastian@undisclosed.invalid> - 2011-07-22 22:37 +0200
Re: Problem with generics and dynamic array copy lewbloch <lewbloch@gmail.com> - 2011-07-22 15:49 -0700
csiph-web