raw type
A generic type used without any type arguments, such as plain List, which turns off the compiler's type checks for it.
In more detail
Raw types exist only for compatibility with code written before Java 5. The compiler reports unchecked warnings when you use them, and wrong-type elements slip in and fail later with a ClassCastException. Keep them out of new code.
Example
List list = new ArrayList(); // raw: avoidRelated terms
- generics — Types that take other types as parameters, so one definition works for many kinds of value.
- diamond operator — The empty angle brackets in new ArrayList<>(), which ask the compiler to infer the constructor's type arguments.
Taught in
- Generics And Collections — Modern Java: Virtual Threads & High-Throughput Services
- Generics, Bounds And Wildcards — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep