Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added normative text

Generically typed code can be freely used with raw types when attempting to preserve compatibility between nongeneric non-generic legacy code and newer generic code. Using raw types with generic code causes most Java compilers to issue "unchecked" warnings but still compile the code. When generic and nongeneric types are used together correctly, these warnings can be ignored; at other times, these warnings can denote potentially unsafe operations.

...

Extending legacy classes and making the overriding methods generic fails because this is disallowed by the Java Language Specification..

Do not use generic types and raw types in the same package, class, or method.

Noncompliant Code Example

...