Morgan Stanley interview question

What are generics?

Interview Answer

Anonymous

12 Sept 2017

Generics help represent the type that is contained in a container class like List or Map so that the compiler can infer type information and provide compile time checks. It also helps remove type casting boilerplate. I gave example code with both generics and non generics syntax to highlight the difference