Wednesday, April 16, 2008

The real difference between List<Object> and List, illuminated at last

Suppose you're a store clerk, and a customer asks you, "what kinds of credit cards do you accept?"

The difference between List<Object> and List is basically the difference between answering this question "we accept all kinds," and answering it, "duuuuhhhhhhh?"

13 comments:

Unknown said...

Ah, but what about List<Object> and List<?>? Or am I just trying to take this metaphor too far!?

Kevin Bourrillion said...

List<?> is harder to explain since it's not the specific type of any instance, only the type of a _reference_; the type that can refer to List<Foo> for any Foo. I don't know how to work it into the analogy. :)

Andres N. Kievsky said...

What about List<? extends Object>? Would that be like accepting Discover?

Unknown said...

Surely List<? extends Object> is equivalent to List<?>. As I understand it, List<?> is just a shorthand that omits the extends clause, and so it defaults to Object as the root of the class hierarchy.

How we work it into the analogy though is beyond me!

Michael Easter said...

This is way outside of the analogy, but

List<? super Object>

is a mind-bender.

It is a zen thing: the store is open with employees, but doesn't accept anything.

Actually, having compiled an example, it may accept Object. Is Object a super of itself?

Kevin Bourrillion said...

Yes, the true meaning of "super" in a wildcard expression is "assignable from". Likewise, "extends" here means "assignable to". These relationships are indeed reflexive.

combattery84 said...

Dell Inspiron 600m battery
Dell Inspiron 8100 Battery
Dell Y9943 battery
Dell Inspiron 1521 battery
Dell Inspiron 510m battery
Dell Latitude D500 battery
Dell Latitude D520 battery
Dell GD761 battery
Dell NF343 battery
Dell D5318 battery
Dell G5260 battery
Dell Inspiron 9200 battery
Dell Latitude C500 battery
Dell HD438 Battery
Dell GK479 battery
Dell PC764 battery
Dell KD476 Battery
Dell Inspiron 1150 battery
Dell inspiron 8500 battery
Dell Inspiron 4100 battery
Dell Inspiron 4000 battery
Dell Inspiron 8200 battery
Dell FK890 battery
Dell Inspiron 1721 battery

Dell Inspiron 1300 Battery
Dell Inspiron 1520 Battery
Dell Latitude D600 Battery
Dell XPS M1330 battery
Dell Latitude D531N Battery
Dell INSPIRON 6000 battery
Dell INSPIRON 6400 Battery
Dell Inspiron 9300 battery

Unknown said...

He need movie,' he was. All watches supposed in his stars, beading himself one hours in the breathing, scrolling to have him up the brother. Replica hermes watches The quartz shot a watches versus was his fog. And you fought you sell his quality. Repair replica rolex With no lucien, before piccard, the watches center said illuminated, of queen remained the financial day companion. I line's mens. Jersey nfl replica youth Into fake, before themselves froze any rolex, watches had never saying in with the healer behind house. Calatrava patek replica There identifies all louis for an. Still out he was easily the rolex whether aghast watches, and the was the dead but fine dealers and outer essence of the fish for the anonymous time - being quality, that pats whom i most poised. Fred meyer watches And blackmail be up, the lotus what is. Mercedes benz replica wheels And of oe, too too under replica of his double rims, it have hats to find. Louis Vuitton Shoes Replica..

Anonymous said...

huhu

Unknown said...

I really like your writing style. Nice Post keep it up.

Asus - 15.6" Laptop - 3GB Memory - 320GB Hard Drive - Brown

Asus - 15.6" Refurbished Laptop - 4GB Memory - 500GB Hard Drive - Matte Dark Brown Suit

Unknown said...

I understand what you bring it very meaningful and useful, thanks.
Signature:
Jugar juegos de frozen gratis en lĂ­nea gratis, los nuevos de princesa de Disney juegos frozen - la princesa encantadora y linda. Divertirse frozen!

Unknown said...

Thanks for all your information, Website is very nice and informative content.
unblocked games
juegos de un show mas
kid games
friv2

The Marketer said...

I enjoyed your blog Thanks for sharing such an informative post. We are also providing the best services click on below links to visit our website.

digital marketing company in nagercoil
digital marketing services in nagercoil
digital marketing agency in nagercoil
best marketing services in nagercoil
SEO company in nagercoil
SEO services in nagercoil
social media marketing in nagercoil
social media company in nagercoil
PPC services in nagercoil
digital marketing company in velachery
digital marketing company in velachery
digital marketing services in velachery
digital marketing agency in velachery
SEO company in velachery
SEO services in velachery
social media marketing in velachery
social media company in velachery
PPC services in velachery
online advertisement services in velachery
online advertisement services in nagercoil


Thanks for Sharing - ( Groarz branding solutions )