In computer science, generics are a technique that allows one value to take different datatypes (so-called polymorphism) as long as certain contracts (so-called subtype) are kept. The programming style with it is called generic programming.
Among OOP languages, C++, D, BETA, Eiffel, Ada, and later versions of Java and C# provide generic facilities. In C++, templates popularized the notion of generics.
For example, if one wanted to create a list using generics, a possible declaration would be to say List<T>, where T represented the type. When instantiated, one could create List<Integer> or List<Animal>. The list then, is treated as a list of whichever type is specified.
Dynamic typing, such featured in Objective-C, and, if necessary, judicious use of protocols circumvent the need for use of generic programming techniques, since there exists a general type to contain any object. Whilst Java does so also, the casting that needs to be done breaks the discipline of static typing, and generics are one way of achieving the benefits of dynamic typing with the advantages of having static typing.
Uncommon, template metaprogramming is a way of making algorithms evaluate when your code is compiled.
External links
See also Partial evaluation