Re: generics & their syntax
- From: "Oliver Wong" <owong@xxxxxxxxxxxxxx>
- Date: Wed, 28 Jun 2006 14:38:53 GMT
<jon23d@xxxxxxxxx> wrote in message news:1151477134.303229.118640@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I've been reading the java tutorial on the sun website, and I keep
running
across this and cannot quite get a grasp of what I'm seeing.
An example:
public class Stack {
private ArrayList<Object> items;
Is
ArrayList<Object> items;
the same as
Object[] items;
???
"Paul Hamaker" <ph@xxxxxxxxxxxxxx> wrote in message news:1151481776.795733.311600@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Nope, it's like the classic
ArrayList items, since that can contain any Object subtype, too.
Then again, Object[] can contain any Object subtype as well...
I'm not sure what missunderstanding the OP may have on generics, but I don't think it's correct to consider ArrayLists as "the same as" an array in general. You got to fix this conceptual barrier before even getting into generics, IMHO.
- Oliver
.
- References:
- generics & their syntax
- From: jon23d
- Re: generics & their syntax
- From: Paul Hamaker
- generics & their syntax
- Prev by Date: Re: array initilization and memory usage
- Next by Date: Re: how to know the api difference in diff version
- Previous by thread: Re: generics & their syntax
- Next by thread: What is CRUD?
- Index(es):