Effective Java! Don’t Use Raw Types

Kyle Carter
4 min readMay 13, 2021

This chapter starts a new section of Effective Java about generics. Before Java 5 where generics were introduced to the language, retrieving items from a collection required a cast of the object being returned. Thankfully, in modern Java, we don’t need to deal with this anymore and can use generics to provide us type safety as well as cleaner code.

Let’s briefly go over the definition of a generic in Java. A generic is a class or interface that has one or more type parameters. The way that this ends up looking is the class or interface name followed by angled brackets…

--

--

Kyle Carter

I'm a software architect that has a passion for software design and sharing with those around me.