Re: A list of ever member in a class.
- From: Tom Hawtin <usenet@xxxxxxxxxxxxxxxxx>
- Date: Tue, 24 Apr 2007 21:39:21 +0100
zero wrote:
Daniel Gee <zefria@xxxxxxxxx> wrote in news:1177371058.868913.54070
@n76g2000hsh.googlegroups.com:
this.elementData = (E[])new Object[initialCapacity];
Yes. Here they are creating an array of Objects, and casting it to an array of Es, which to the compiler is quite different from creating an array of Es directly.
If the people implementing ArrayList have to resort to this kind of tricks, maybe it should've made them wonder at the validity of generics.
It is not necessary to do this sort of cast in order to implement ArrayList. It's just to avoid lots of unchecked casts whenever an element is read from the array.
Anyway, now that ArrayList has been implemented, we can all use List instead of reference arrays. Even if ArrayList were implemented natively, the implementation still would not make any difference to other code.
Tom Hawtin
.
- References:
- A list of ever member in a class.
- From: Hakusa@xxxxxxxxx
- Re: A list of ever member in a class.
- From: Daniel Gee
- Re: A list of ever member in a class.
- From: zero
- Re: A list of ever member in a class.
- From: Daniel Gee
- Re: A list of ever member in a class.
- From: zero
- A list of ever member in a class.
- Prev by Date: Re: A list of ever member in a class.
- Next by Date: Looking for an open source xml editor
- Previous by thread: Re: A list of ever member in a class.
- Next by thread: Re: A list of ever member in a class.
- Index(es):
Relevant Pages
|