List
out of, since it's just a whole bunch of objects put together.<>
and can be appended to methods and classes. Here's an example with classes:SomeType
is a Generic Type Variable that is not a real type, but can still be used inside the class as normal.String
is an Actual Type Argument that replaces SomeType
during runtime. Now, every time SomeType
is used in SomeClass
Java treats it exactly like a String
.ArrayStoreException
if types are mismatched in any way.Number
.List<int>
is invalid and will not work!Integer
, Boolean
, Character
and so on. However, converting between these types and primitive types, which is called autoboxing, has significant performance penalties that must be taken into consideration.new List<X>() instanceof List<Y>
will always be true regardless of what types X and Y are.