Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Generics, damned if you do, damned if you don't

Reply
Thread Tools

Generics, damned if you do, damned if you don't

 
 
Roedy Green
Guest
Posts: n/a
 
      07-03-2007
On Tue, 03 Jul 2007 20:20:03 GMT, Roedy Green
<(E-Mail Removed)> wrote, quoted or indirectly quoted
someone who said :

>It is not different. It just not the problem we were talking about,
>arrays of generics. Look in the code sample about autoboxing.


The code you quoted is an array of ordinary Strings, not an array of
generics. The problem comes here when you try to allocate an array of
generics:

// extract key/value pair entries into an array
Set<Map.Entry<String, Integer>> justEntries =
h.entrySet();
// Infuriatingly, this generates an unchecked conversion
warning message.
Map.Entry<String, Integer>[] keyValuePairs =
justEntries.toArray( new
Map.Entry[justEntries.size()] );
// Type erasure won't let us say:
// Map.Entry<String, Integer>[] keyValuePairs =
// justEntries.toArray ( new
// Map.Entry<String,Integer>[justEntries.size()] );

--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Damned red arrow won't go away! Captain Infinity Firefox 7 07-30-2005 03:38 PM
Damned DSL Computer Support 4 07-26-2005 07:27 PM
Damned attachment MayB Computer Support 4 12-19-2004 03:28 AM
Damned Container.... Nicolas Java 2 08-04-2003 03:42 AM
"Heretic: City of the Damned" cheatsheet? Max Quordlepleen Computer Support 4 06-28-2003 04:32 AM



Advertisments