Generics in Java

Generics are a facility of generic programming that were added to the Java programming language in 2004 within version J2SE 5.0. They were designed to extend Java's type system to allow "a type or method to operate on objects of various types while providing compile-time type safety".[1] The aspect compile-time type safety required that parametrically polymorphic functions are not implemented in the Java virtual machine, since type safety is impossible in this case.[2][3]

The Java collections framework supports generics to specify the type of objects stored in a collection instance.

In 1998, Gilad Bracha, Martin Odersky, David Stoutamire and Philip Wadler created Generic Java, an extension to the Java language to support generic types.[4] Generic Java was incorporated in Java with the addition of wildcards.

  1. ^ Java Programming Language
  2. ^ A ClassCastException can be thrown even in the absence of casts or nulls."Java and Scala's Type Systems are Unsound" (PDF).
  3. ^ Bloch 2018, pp. 123–125, Chapter §5 Item 27: Eliminate unchecked warnings.
  4. ^ GJ: Generic Java

© MMXXIII Rich X Search. We shall prevail. All rights reserved. Rich X Search