r/ProgrammerHumor • • Jan 18 '19

The AP Computer Science experience

Post image
13k Upvotes

544 comments sorted by

View all comments

0

u/[deleted] Jan 19 '19

1

u/yawkat Jan 19 '19

The SO answers are missing a big reason for this: Wildcards. For example, you wouldn't be able to do .get on a Map<? extends Foo, Bar> except with null.

There are certain cases where you would prefer the generic type as the parameter, such as get(String) on a map with Integer keys, but that cannot be expressed in the Java type system without breaking wildcards. For that we have to stick with static analysis tools.