Re: generics & their syntax



<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

.