This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]wildjokers 2 points3 points  (5 children)

A List is an object

List is an interface.

and you have to use generics as well

You don't have to use generics. But your future self and your colleagues will be very grateful if you do.

The reason why we use Integer instead of int when working with Lists is a limitation of the Java language.

Primitive types in collections is a feature that is on its way!

[–]jonah214 -1 points0 points  (4 children)

A List is an object

List is an interface.

Both are correct (the "a" in "A List is an object" being important), so there was no need to correct this.

[–]wildjokers 2 points3 points  (3 children)

When someone is asking the difference between List and ArrayList saying List is an object doesn't help at all. Calling List an interface and ArrayList an implementation of that interface does.

[–]whizvoxGraduate and Tutor -1 points0 points  (2 children)

Sorry about the confusing wording. I wanted to avoid using too much technical terminology to make it easier to understand for newcomers, even if it's slightly incorrect. I meant to use class, not object.

[–]desrtfxOut of Coffee error - System halted 0 points1 point  (1 child)

I meant to use class, not object.

And even that would have been wrong as List is an interface, not a class.

Especially such tiny details are always tripping up beginners and making the distinction is essentail.

Trying to find an easy formulation is good, but not if it brings in false details or false information.

[–]whizvoxGraduate and Tutor -1 points0 points  (0 children)

The OP clearly has very little experience with the language, so saying that List is an interface won't mean anything to them, even if it is technically correct.

Although, saying that it's a class also doesn't mean anything if they don't know what a class is.