Java Java Data Structures Exploring the Java Collection Framework Meet the JCF

More explantion about generics

Hi, So generics is basically lets us to get rid of the need for cast the object to the type we want to in iorder to access his properties? any insights regarding that matter will be appriciated.

Steven Parker

2 Answers

Steven Parker
Steven Parker
200,760 Points

:bell: Hi, I got alerted by your tag.

I wouldn't say generics replace casting, but they do eliminate the need to create separate versions for different data types.generics allow the method to conform to the type you need directly, so no conversion is occurring.