嗨!我们继续我们关于仿制药的一系列课程。我们之前大致了解了它们是什么以及为什么需要它们。今天,我们将更多地了解通用的一些功能以及与它们一起工作。我们走吧!在上一课中,我们讨论了通用类型和原始类型之间的区别。原始类型是一个通用类,其类型已被删除。List list = new ArrayList();这里有一个例子。在这里,我们没有指示将什么类型的对象放在我们的List。如果我们尝试创建这样的List并向其添加一些对象,我们将在IDEA中看到一个警告:"Unchecked call to add(E) as a member of raw type of java.util.List".But we also talked about the fact that generics appeared only in Java 5. By the time this version was released, programmers had already written a bunch of code using raw types, so this feature of the language could not stop working, and the ability to create raw types in Java was preserved. However, the problem turned out to be more widespread. As you know, Java code is converted to a special compiled format called bytecode, which is then executed by the Java virtual machine. But if we put information about type parameters in the bytecode during the conversion process, it would break all the previously written code, because there were no type parameters before Java 5! When working with generics, there is one very important concept that you need to remember. It is called type erasure. It means that a class contains no information about a type parameter. This information is available only during compilation and is erased (becomes inaccessible) before runtime. If you try to put the wrong type of object in yourListString, the compiler will generate an error. This is exactly what the language's creators want to achieve when they created generics: compile-time checks. But when all your Java code turns into bytecode, it no longer contains information about type paramet