[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.java.programmer

Re: array of HashSet<>

Re: array of HashSet<>

Daniel Pitts

6/11/2016 7:30:00 PM

On 6/10/16 12:25 PM, Lew wrote:
> Roedy Green wrote:
>> Daniel Pitts wrote:
>>> Simplest work-around: Use a List<Set<>> instead.
>>
>> Is what you are doing there just buryng the dirty work under the
>> covers? inside ArrayList?
>
> What do you mean by "just burying"? Is there something wrong with simplifying "dirty work"?
>
> And teasing out the objective part of your question from the purple prose, no, it isn't. Arrays in Java are not generic, and there is an explicit prohibition of making arrays out of non-reifiable types. These restrictions do not apply to generic collections, obviously. So no, it isn't "just" anything, let alone "burying" some sort of "dirty" work. It's allowing the compiler to check your type assertions at compile time.
>
To be fair, ArrayList<T> is implemented with a lot of "unsafe" type
casting. The difference is that the ArrayList implementation is
guaranteed to be type-safe if generics are used.

So in a way it does the dirty work for you, but that isn't the same as
burying it. Since someone else has done the dirty work, why not take
advantage of that, and use the proven type-safe interface.

Not to mention, it is often preferable to use less-primitive types that
describe the entity you need. Arrays are more primitive than Collection
implementations.



Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: array of HashSet<>

Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te

Il servizio è completamente GRATUITO!