Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What is java pseudo generics?

Shulou Source: shulou.com Published: 2022-05-31 10:52:52 09月23日 Update

This article mainly introduces the relevant knowledge of "what is java pseudo-generics". The editor shows you the operation process through actual cases, and the operation method is simple, fast and practical. I hope this article "what is java pseudo-generics" can help you solve the problem.

Description

1. Generics in Java are pseudo-generics. This generic implementation method is called type erasure, and generics implemented based on this method are called pseudo-generics.

2. Because Java generics only play a role in the compilation phase, they play a role of checking when writing code.

When the code runs, there are no generics inside it.

Example

List L1 = new ArrayList (); List L2 = new ArrayList (); System.out.println (l1.getClass () = = l2.getClass ()); / / true

The result is that the Class of both true,List and List in jvm is List.class, that is, the generic information is erased.

What are the collection classes in Java? the collections in Java are divided into four main categories:

1. List list: ordered and repeatable

2. Queue queue: orderly and repeatable

3. Set collection: non-repeatable

4. Map mapping: unordered, key unique, value not unique.

This is the end of the content about "what is java pseudo generics". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Tags: Methods knowledge order code function industry different practical information content examples practicality practice articles more cases knowledge points articles types results Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Technology MySQL Huawei Shulou Tech Info