Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Generics in Java!
You have completed Generics in Java!
Preview
In this video we'll learn more about generics and implement our first type parameter!
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Ideally, this error would be caught
much sooner by the compiler or
0:00
even by IntelliJ.
0:02
And it would show us
the error on lines 12 and 13.
0:03
To make it show us the error,
0:06
we need a way to designate each of our
boxes as only allowing a certain type.
0:08
Which we can do with generics.
0:14
Let's head over to Box.java and
use our first generic.
0:17
At the top of the class,
directly after the word Box,
0:22
let's type a less than sign, which
will automatically add its other half.
0:25
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up