Generics were added to the Java language more than 10 year ago. But do you really understand them?
Well discuss:
What is heap pollution?
How does the compiler translate generics?
Why its 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 its not allowed to add Integer to List<?>
Why its not allowed to parameterize exception classes?
Whats wrong with Collections.max signature: <t><?>> T max(Collection<?> coll);
Code that should be compiled, but cant be compiled and vice versa
How to write good API using generics and wildcards
And other generic puzzlers
Generics were added to the Java language more than 10 year ago. But do you really understand them?
Well discuss:
What is heap pollution?
How does the compiler translate generics?
Why its 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 its not allowed to add Integer to List<?>
Why its not allowed to parameterize exception classes?
Whats wrong with Collections.max signature: <t><?>> T max(Collection<?> coll);
Code that should be compiled, but cant be compiled and vice versa
How to write good API using generics and wildcards
And other generic puzzlers
12. 亠亠仄亠仆仆亠
弍磦仍亠仆亳亠 仗亠亠仄亠仆仆:
<type> identifier [ = value ] [, identifier [ = value ] ... ];
byte b = 055;
short s = 0x55ff;
int i = 1000000;
long l = 0xffffffffL;
char = 'a' ;
float f = .25f;
double d = .00001234;
boolean bool = true;
12