Tricky Java Generics
Generics were added to the Java language more than 10 year ago. But do you really understand them?
- What is heap pollution?
- How does the compiler translate generics?
- Why it’s not allowed to create parametrized array (List<String>)
- What are bridge methods, can we reach them?
- Type erasure rules
- Difference between List, List<Object>, List<?>
- Why it’s not allowed to add Integer to List<? extends Number>
- Why it’s not allowed to parameterize exception classes?
- What’s wrong with Collections.max signature: <T extends Object & Comparable<? super T>> T max(Collection<? extends T> coll);
- Code that should be compiled, but can’t be compiled and vice versa
- How to write good API using generics and wildcards
- And other generic puzzlers
About the speaker
to add slides, notes or videos to this session