Take notes to tidy up ~ ~ ~
First, the concept of the heap object is drawn.
What is a heap object is an object that the program can create or delete at any time while it is running, either with the new operator (or the malloc function) or the delete operator (or the free function). Generics can be thought of as a class of heap objects.
Generics are a feature of programming languages. Allows programmers to define variable parts when writing code in a strongly typed programming language, which must be specified before they are used.
The various programming languages and their compilers and operating environments have different support for generics. Parameterization of the type to achieve code reuse a data type that improves the productivity of software development.
There are two main types of generics:
1. In program encoding, some types that contain type parameters , that is, generic parameters can only represent classes, cannot represent individual objects. (This is the more common definition of today)
2. Some classes that contain parameters in the program code. Its parameters can represent classes or objects, and so on. (Most people call this a template) regardless of which definition is used, the generic parameter must be specified when the generic is actually used .
Https://docs.microsoft.com/zh-cn/dotnet/csharp/programming-guide/generics/generic-classes This is Microsoft's explanation for generic classes.
It points out that generic classes are most commonly used in collections, such as linked lists, hash tables, stacks, queues, trees, and so on. Operations like adding and removing items from a collection are performed in substantially the same way regardless of the type of data being stored.
Knowing the definition, what are the benefits of using generics? This concludes with a look at generics in Java.
Generics in Java:
Generics in generics and Java